Файл: app/Traits/PollableTrait.php
Строк: 24
<?php
declare(strict_types=1);
namespace AppTraits;
use AppModelsPoll;
use IlluminateDatabaseEloquentRelationsMorphMany;
use IlluminateDatabaseEloquentRelationsMorphOne;
trait PollableTrait
{
/**
* Возвращает связь с голосованиями
*
* @return MorphMany<Poll, $this>
*/
public function polls(): MorphMany
{
return $this->morphMany(Poll::class, 'relate');
}
/**
* Возвращает связь с голосованием текущего пользователя
*
* @return MorphOne<Poll, $this>
*/
public function poll(): MorphOne
{
return $this->morphOne(Poll::class, 'relate')
->where('user_id', getUser('id'));
}
}