forked from eatvio/eatvio-infra
75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Iben\Statable\Statable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* App\Models\ChosenDiet
|
|
*
|
|
* @property int $id
|
|
* @property int|null $diet_id
|
|
* @property int $user_id
|
|
* @property string $last_state
|
|
* @property string $start_date
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
*
|
|
* @property-read \App\Models\Diet|null $diet
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Iben\Statable\Models\StateHistory> $stateHistory
|
|
* @property-read int|null $state_history_count
|
|
* @property-read \App\Models\User|null $user
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereDietId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereLastState($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereStartDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|ChosenDiet whereUserId($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class ChosenDiet extends Model
|
|
{
|
|
use HasFactory, Statable;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'diet_id',
|
|
'last_state',
|
|
'start_date',
|
|
];
|
|
|
|
public function getActorId(): int
|
|
{
|
|
return $this->user_id;
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function diet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Diet::class);
|
|
}
|
|
|
|
protected function getGraph(): string
|
|
{
|
|
return 'chosen_diet';
|
|
}
|
|
|
|
protected function saveBeforeTransition(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|