mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-25 11:09:17 +01:00
30 lines
586 B
PHP
30 lines
586 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Concerns\Models\Aggregate;
|
|
|
|
use App\Models\Aggregate\LikeAggregate;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
/**
|
|
* Trait AggregatesLike.
|
|
*/
|
|
trait AggregatesLike
|
|
{
|
|
final public const RELATION_LIKE_AGGREGATE = 'likeAggregate';
|
|
|
|
/**
|
|
* Get the likes count of the model.
|
|
*
|
|
* @return MorphOne<LikeAggregate, $this>
|
|
*/
|
|
public function likeAggregate(): MorphOne
|
|
{
|
|
return $this->morphOne(
|
|
LikeAggregate::class,
|
|
LikeAggregate::ATTRIBUTE_LIKEABLE,
|
|
);
|
|
}
|
|
}
|