forked from eatvio/eatvio-infra
36 lines
670 B
PHP
36 lines
670 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\UserAttachment;
|
|
|
|
class Meal extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $fillable = ['*'];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault([
|
|
'name' => 'Guest Author',
|
|
]);
|
|
}
|
|
|
|
public function diary()
|
|
{
|
|
return $this->belongsTo(Diary::class);
|
|
}
|
|
|
|
public function portions()
|
|
{
|
|
return $this->hasMany(Portion::class);
|
|
}
|
|
|
|
public function photos()
|
|
{
|
|
return $this->belongsToMany(UserAttachment::class);
|
|
}
|
|
}
|