psalm-plugin-laravel/tests/Models/Tag.php
2022-02-10 17:45:51 +01:00

32 lines
698 B
PHP

<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
final class Tag extends Model
{
protected $table = 'tags';
/**
* Get all of the posts that are assigned this tag.
* @psalm-return MorphToMany<Post>
*/
public function posts(): MorphToMany
{
return $this->morphedByMany(Post::class, 'taggable');
}
/**
* Get all of the videos that are assigned this tag.
* @psalm-return MorphToMany<Video>
*/
public function videos(): MorphToMany
{
return $this->morphedByMany(Video::class, 'taggable');
}
}