Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use App\Models\Concerns\UsesStringIds;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany as UserHasMany;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, UsesStringIds;
|
||||
|
||||
public const CREATED_AT = 'createdAt';
|
||||
public const UPDATED_AT = 'updatedAt';
|
||||
|
||||
protected $table = 'User';
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'phone', 'passwordHash', 'isSuperAdmin',
|
||||
];
|
||||
|
||||
protected $hidden = ['passwordHash', 'remember_token'];
|
||||
|
||||
public function getAuthPasswordName(): string
|
||||
{
|
||||
return 'passwordHash';
|
||||
}
|
||||
|
||||
public function getAuthPassword(): ?string
|
||||
{
|
||||
return $this->passwordHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'emailVerified' => 'datetime',
|
||||
'phoneVerified' => 'datetime',
|
||||
'isSuperAdmin' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function customerProfiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerProfile::class, 'userId');
|
||||
}
|
||||
|
||||
public function staffProfiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(StaffProfile::class, 'userId');
|
||||
}
|
||||
|
||||
public function receivedNotifications(): UserHasMany { return $this->hasMany(Notification::class, 'recipientUserId'); }
|
||||
public function notificationPreferences(): UserHasMany { return $this->hasMany(NotificationPreference::class, 'userId'); }
|
||||
public function pushSubscriptions(): UserHasMany { return $this->hasMany(PushSubscription::class, 'userId'); }
|
||||
public function uploadedMediaAssets(): UserHasMany { return $this->hasMany(MediaAsset::class, 'uploadedByUserId'); }
|
||||
public function sentStaffInvitations(): UserHasMany { return $this->hasMany(StaffInvitation::class, 'invitedByUserId'); }
|
||||
}
|
||||
Reference in new issue
Block a user