mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
20 lines
363 B
PHP
20 lines
363 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use App\Models\Star;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
trait HasStars
|
|
{
|
|
public static function bootHasStars(): void
|
|
{
|
|
static::deleted(fn ($model) => $model->stars()->delete());
|
|
}
|
|
|
|
public function stars(): MorphMany
|
|
{
|
|
return $this->morphMany(Star::class, 'starrable');
|
|
}
|
|
}
|