forked from eatvio/eatvio-infra
74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* App\Models\Meal
|
|
*
|
|
* @property int $id
|
|
* @property int|null $user_id
|
|
* @property int|null $diary_id
|
|
* @property string $time
|
|
* @property int $type
|
|
* @property int $satiety
|
|
* @property int $mood
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
*
|
|
* @property-read \App\Models\Diary|null $diary
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\UserAttachment> $photos
|
|
* @property-read int|null $photos_count
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Portion> $portions
|
|
* @property-read int|null $portions_count
|
|
* @property-read \App\Models\User|null $user
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereDiaryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereMood($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereSatiety($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereTime($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Meal whereUserId($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Meal extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['*'];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault([
|
|
'name' => 'Guest Author',
|
|
]);
|
|
}
|
|
|
|
public function diary(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Diary::class);
|
|
}
|
|
|
|
public function portions(): HasMany
|
|
{
|
|
return $this->hasMany(Portion::class);
|
|
}
|
|
|
|
public function photos(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(UserAttachment::class);
|
|
}
|
|
}
|