forked from eatvio/eatvio-infra
eating plan added
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user