belongsTo(User::class)->withDefault([ 'name' => 'Guest Author', ]); } public function meals() { return $this->hasMany(Meal::class); } public function scopeUserToDayItem($query, $userId) { return $query ->where('user_id', $userId) ->where('date', now()->format('Y-m-d')); } }