2026-03-19 18:18:18 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
|
use Database\Factories\UserFactory;
|
2026-03-19 23:45:46 -06:00
|
|
|
use Filament\Models\Contracts\FilamentUser;
|
|
|
|
|
use Filament\Panel;
|
2026-03-19 18:18:18 -06:00
|
|
|
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;
|
|
|
|
|
|
2026-03-19 23:45:46 -06:00
|
|
|
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'is_admin', 'password'])]
|
2026-03-19 18:18:18 -06:00
|
|
|
#[Hidden(['password', 'remember_token'])]
|
2026-03-19 23:45:46 -06:00
|
|
|
class User extends Authenticatable implements FilamentUser
|
2026-03-19 18:18:18 -06:00
|
|
|
{
|
|
|
|
|
/** @use HasFactory<UserFactory> */
|
|
|
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'first_name',
|
|
|
|
|
'last_name',
|
2026-03-28 12:36:12 -06:00
|
|
|
'username',
|
2026-03-19 18:18:18 -06:00
|
|
|
'email',
|
|
|
|
|
'phone',
|
2026-03-19 23:45:46 -06:00
|
|
|
'is_admin',
|
2026-03-19 18:18:18 -06:00
|
|
|
'password',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $appends = ['name'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'email_verified_at' => 'datetime',
|
2026-03-19 23:45:46 -06:00
|
|
|
'is_admin' => 'boolean',
|
2026-03-19 18:18:18 -06:00
|
|
|
'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),
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-03-19 23:45:46 -06:00
|
|
|
|
|
|
|
|
public function canAccessPanel(Panel $panel): bool
|
|
|
|
|
{
|
|
|
|
|
return $panel->getId() === 'admin' && $this->is_admin;
|
|
|
|
|
}
|
2026-03-19 18:18:18 -06:00
|
|
|
}
|