59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||
|
|
use Database\Factories\UserFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||
|
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||
|
|
use Illuminate\Notifications\Notifiable;
|
||
|
|
use Laravel\Sanctum\HasApiTokens;
|
||
|
|
|
||
|
|
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'password'])]
|
||
|
|
#[Hidden(['password', 'remember_token'])]
|
||
|
|
class User extends Authenticatable
|
||
|
|
{
|
||
|
|
/** @use HasFactory<UserFactory> */
|
||
|
|
use HasApiTokens, HasFactory, Notifiable;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'first_name',
|
||
|
|
'last_name',
|
||
|
|
|
||
|
|
'email',
|
||
|
|
'phone',
|
||
|
|
'password',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $appends = ['name'];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the attributes that should be cast.
|
||
|
|
*
|
||
|
|
* @return array<string, string>
|
||
|
|
*/
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'email_verified_at' => 'datetime',
|
||
|
|
'password' => 'hashed',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function picks(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(Pick::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function name(): Attribute
|
||
|
|
{
|
||
|
|
return Attribute::make(
|
||
|
|
get: fn (): string => trim($this->first_name.' '.$this->last_name),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|