eating plan added

This commit is contained in:
Anatoliy Poloz
2022-07-27 14:53:16 +00:00
parent 0f1cafb518
commit a9601ab15d
146 changed files with 37111 additions and 127 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Meal;
use Illuminate\Database\Eloquent\Casts\Attribute;
class Diary extends Model
{
@@ -28,4 +29,16 @@ class Diary extends Model
->where('user_id', $userId)
->where('date', now()->format('Y-m-d'));
}
public function consultant_comments()
{
return $this->hasMany(ConsultantDiaryComment::class);
}
protected function hasComments(): Attribute
{
return Attribute::make(
get: fn () => $this->consultant_comments()->count() > 0,
);
}
}