psalm-plugin-laravel/tests/Models/Tag.php

29 lines
697 B
PHP
Raw Normal View History

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