forked from eatvio/eatvio-infra
113 lines
2.5 KiB
PHP
113 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Auth\MustVerifyEmail as UserMustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Fortify\TwoFactorAuthenticatable;
|
|
use Laravel\Jetstream\HasProfilePhoto;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use App\Models\UserDetailz;
|
|
use App\Models\CircumferenceMeasure;
|
|
use App\Models\WeightMeasure;
|
|
use App\Models\ConsultantEducation;
|
|
use App\Models\UserAttachment;
|
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasApiTokens;
|
|
use HasFactory;
|
|
use HasProfilePhoto;
|
|
use Notifiable;
|
|
use TwoFactorAuthenticatable;
|
|
use UserMustVerifyEmail;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
'two_factor_recovery_codes',
|
|
'two_factor_secret',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* The accessors to append to the model's array form.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $appends = [
|
|
'profile_photo_url',
|
|
];
|
|
|
|
public function diaries()
|
|
{
|
|
return $this->hasMany(Diary::class);
|
|
}
|
|
|
|
public function meals()
|
|
{
|
|
return $this->hasMany(Meal::class);
|
|
}
|
|
|
|
public function detailz()
|
|
{
|
|
return $this->hasOne(UserDetailz::class);
|
|
}
|
|
|
|
public function circumference_measures()
|
|
{
|
|
return $this->hasMany(CircumferenceMeasure::class);
|
|
}
|
|
|
|
public function weight_measures()
|
|
{
|
|
return $this->hasMany(WeightMeasure::class);
|
|
}
|
|
|
|
public function consultant_request()
|
|
{
|
|
return $this->hasOne(ConsultantEducation::class);
|
|
}
|
|
|
|
public function attachments()
|
|
{
|
|
return $this->hasMany(UserAttachment::class);
|
|
}
|
|
|
|
protected function consultantState(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->consultant_request ? $this->consultant_request->request_state : 'incomplete',
|
|
);
|
|
}
|
|
|
|
}
|