*/ use HasFactory; protected $fillable = ['user_dish_id', 'recurrence_id', 'recurrence_type']; protected $casts = []; public function recurrence(): MorphTo { return $this->morphTo(); } public function dishUser(): BelongsTo { return $this->belongsTo(UserDish::class, 'user_dish_id', 'id'); } /** * @throws InvalidRecurrenceTypeException */ public function getValue(): int { return match ($this->recurrence_type) { WeeklyRecurrence::class => $this->recurrence->weekday->value, MinimumRecurrence::class => $this->recurrence->days, default => throw new InvalidRecurrenceTypeException }; } }