store/app/Models/UserProfile.php

35 lines
723 B
PHP

<?php
namespace App\Models;
use App\Enums\Gender;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
#[Guarded(['id'])]
class UserProfile extends Model
{
use SoftDeletes;
protected function casts(): array
{
return [
'gender' => Gender::class,
'birth_date' => 'date',
];
}
public function employee(): HasOne
{
return $this->hasOne(Employee::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}