forked from eatvio/eatvio-infra
init commit
This commit is contained in:
31
app/Models/Diary.php
Normal file
31
app/Models/Diary.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Meal;
|
||||
|
||||
class Diary extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user