Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't specify morphTo name for lti environment, so the correct name is inferred #16

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ parameters:
- tests
- workbench
tmpDir: build/phpstan
checkMissingIterableValueType: false
2 changes: 1 addition & 1 deletion src/ModelDataConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function savePlatform(CelticPlatform $platform): bool
return false;
}

$platform->updated = $clientModel->updated_at->getTimestamp();
$platform->updated = $clientModel->getAttribute($clientModel->getUpdatedAtColumn())->getTimestamp();

return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Models/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasLtiEnvironment;

/**
* @property string $id
* @property string $access_token
* @property array $scopes
* @property \Illuminate\Support\Carbon $expires_at
* @property string $id
* @property string $access_token
* @property array $scopes
* @property \Illuminate\Support\Carbon $expires_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
Expand Down
14 changes: 7 additions & 7 deletions src/Models/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasLtiEnvironment;

/**
* @property int $id
* @property string|null $title
* @property string $external_context_id
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int $id
* @property string|null $title
* @property string $external_context_id
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Database\Eloquent\Collection<int, \Swis\Laravel\LtiProvider\Models\ResourceLink> $resourceLinks
* @property int|null $resource_links_count
* @property int|null $resource_links_count
*
* @method static \Illuminate\Database\Eloquent\Builder|Context newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Context newQuery()
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Contracts/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* @property int $nr
* @property string $name
* @property int $nr
* @property string $name
* @property \DateTime $updated_at
*/
interface Client
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Nonce.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasLtiEnvironment;

/**
* @property string $id
* @property string $nonce
* @property \Illuminate\Support\Carbon $expires_at
* @property string $id
* @property string $nonce
* @property \Illuminate\Support\Carbon $expires_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
Expand Down
16 changes: 8 additions & 8 deletions src/Models/ResourceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasLtiEnvironment;

/**
* @property int $id
* @property int|null $lti_context_id
* @property string|null $title
* @property string $external_resource_link_id
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int $id
* @property int|null $lti_context_id
* @property string|null $title
* @property string $external_resource_link_id
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Swis\Laravel\LtiProvider\Models\Context|null $context
* @property int|null $user_results_count
* @property int|null $user_results_count
*
* @method static \Illuminate\Database\Eloquent\Builder|ResourceLink newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ResourceLink newQuery()
Expand Down
24 changes: 12 additions & 12 deletions src/Models/SimpleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasClientCapabilities;

/**
* @property int $id
* @property string $name
* @property string $key
* @property string|null $secret
* @property string|null $public_key
* @property string|null $lti_platform_id
* @property string|null $lti_client_id
* @property string|null $lti_deployment_id
* @property string|null $lti_version
* @property string $lti_signature_method
* @property int $id
* @property string $name
* @property string $key
* @property string|null $secret
* @property string|null $public_key
* @property string|null $lti_platform_id
* @property string|null $lti_client_id
* @property string|null $lti_deployment_id
* @property string|null $lti_version
* @property string $lti_signature_method
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $lti_profile
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $lti_settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
* @method static \Illuminate\Database\Eloquent\Builder|SimpleClient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|SimpleClient newQuery()
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Traits/HasClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
* @property string|int $client_id
* @property string|int $client_id
* @property \Illuminate\Database\Eloquent\Model&\Swis\Laravel\LtiProvider\Models\Contracts\Client $client
*
* @method static \Illuminate\Database\Eloquent\Builder|static whereClientId($value)
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Traits/HasLtiEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Database\Eloquent\Relations\MorphTo;

/**
* @property string $lti_environment_type
* @property string $lti_environment_id
* @property string $lti_environment_type
* @property string $lti_environment_id
* @property \Illuminate\Database\Eloquent\Model&\Swis\Laravel\LtiProvider\Models\Contracts\LtiEnvironment $ltiEnvironment
*
* @method static \Illuminate\Database\Eloquent\Builder|static whereLtiEnvironmentId($value)
Expand All @@ -22,6 +22,6 @@ trait HasLtiEnvironment
public function ltiEnvironment(): MorphTo
{
/** @phpstan-ignore-next-line */
return $this->morphTo('lti_environment');
return $this->morphTo();
}
}
12 changes: 6 additions & 6 deletions src/Models/UserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasLtiEnvironment;

/**
* @property int $id
* @property int $lti_resource_link_id
* @property string $external_user_id
* @property string $external_user_result_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int $id
* @property int $lti_resource_link_id
* @property string $external_user_id
* @property string $external_user_result_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Swis\Laravel\LtiProvider\Models\ResourceLink $resourceLink
*
* @method static \Illuminate\Database\Eloquent\Builder|UserResult newModelQuery()
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelDataConnector/ModelDataConnectorTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function it_should_load_platform(): void
$platform = Platform::fromRecordId($client->getLtiRecordId(), $this->connector);

// Assert
$this->assertEquals($client->name, $platform->name);
$this->assertEquals($client->getAttribute('name'), $platform->name);
}

/** @test */
Expand Down
4 changes: 2 additions & 2 deletions workbench/app/Models/SimpleLtiEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Swis\Laravel\LtiProvider\Models\Traits\IsLtiEnvironment;

/**
* @property int $id
* @property string $name
* @property int $id
* @property string $name
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
Expand Down
24 changes: 12 additions & 12 deletions workbench/app/OverrideModels/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
use Swis\Laravel\LtiProvider\Models\Traits\HasClientCapabilities;

/**
* @property string $id
* @property int $nr
* @property string $name
* @property string|null $secret
* @property string|null $public_key
* @property string|null $lti_platform_id
* @property string|null $lti_client_id
* @property string|null $lti_deployment_id
* @property string|null $lti_version
* @property string $lti_signature_method
* @property string $id
* @property int $nr
* @property string $name
* @property string|null $secret
* @property string|null $public_key
* @property string|null $lti_platform_id
* @property string|null $lti_client_id
* @property string|null $lti_deployment_id
* @property string|null $lti_version
* @property string $lti_signature_method
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $lti_profile
* @property \Illuminate\Database\Eloquent\Casts\ArrayObject $lti_settings
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
* @method static \Illuminate\Database\Eloquent\Builder|Client newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Client newQuery()
Expand Down
4 changes: 2 additions & 2 deletions workbench/app/OverrideModels/SimpleLtiEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Swis\Laravel\LtiProvider\Models\Traits\IsLtiEnvironment;

/**
* @property string $id
* @property string $name
* @property string $id
* @property string $name
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
Expand Down
Loading