$tickets * @mixin \Eloquent */ class Label extends Model { use HasFactory; /** * Indicates if the model should be timestamped. * * @var boolean */ public $timestamps = false; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'color' => HtmlColor::class, ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'color' ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted() { 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() { return $this->belongsToMany(Ticket::class); } /** * BelongsTo Site relation * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function site() { return $this->belongsTo(Site::class); } }