'float', 'carbohydrates' => 'float', 'cholesterol' => 'float', 'date' => 'datetime:Y-m-d', 'fat' => 'float', 'protein' => 'float', 'sodium' => 'float', ]; /** * @inheritdoc */ protected $with = ['user', 'foods:id,name,slug', 'recipes:id,name,slug']; /** * Get all supported meals and metadata. * * Each entry has two keys: * - value: Machine name for the meal. * - label: Human-readable name for the meal. * * @return \Illuminate\Support\Collection */ public static function meals(): Collection { return new Collection([ [ 'value' => 'breakfast', 'label' => 'Breakfast' ], [ 'value' => 'lunch', 'label' => 'Lunch'], [ 'value' => 'dinner', 'label' => 'Dinner'], [ 'value' => 'snacks', 'label' => 'Snacks'], ]); } /** * Get the User this entry belongs to. */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get all foods related to this entry. */ public function foods(): MorphToMany { return $this->morphedByMany(Food::class, 'journalable'); } /** * Get all recipes related to this entry. */ public function recipes(): MorphToMany { return $this->morphedByMany(Recipe::class, 'journalable'); } }