*/ protected $casts = [ 'color' => HtmlColor::class, ]; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'color' ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $model) { ToolboxHelper::assertIsUnique($model, ['name']); }); static::updating(function (self $model) { ToolboxHelper::assertIsUnique($model, ['name']); }); } // * RELATIONSHIPS /** * BelongsToMany Ticket relation * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function tickets(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { return $this->belongsToMany(Ticket::class); } /** * BelongsTo Site relation * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function site(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Site::class); } }