initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\HasUuid;
|
||||
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\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'birthdate', 'password', 'locale'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasApiTokens, HasFactory, HasUuid, Notifiable, SoftDeletes;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'birthdate' => 'date',
|
||||
'email_verified_at' => 'datetime',
|
||||
'anonymized_at' => 'datetime',
|
||||
'is_active' => 'boolean',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
protected function fullName(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
fn (): string => trim("{$this->first_name} {$this->last_name}")
|
||||
);
|
||||
}
|
||||
|
||||
public function wallet(): HasOne
|
||||
{
|
||||
return $this->hasOne(Wallet::class);
|
||||
}
|
||||
|
||||
public function bookings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function washes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Wash::class);
|
||||
}
|
||||
|
||||
public function gdprConsents(): HasMany
|
||||
{
|
||||
return $this->hasMany(GdprConsent::class);
|
||||
}
|
||||
|
||||
public function notificationPreference(): HasOne
|
||||
{
|
||||
return $this->hasOne(NotificationPreference::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user