Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
|
|
/**
|
|
* Thin local mirror of the platform identity (auth.ladill.com owns users).
|
|
* Keyed by the OIDC `sub` (public_id); every CRM record is scoped to it.
|
|
*/
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, Notifiable;
|
|
|
|
protected $fillable = ['public_id', 'name', 'email', 'avatar_url', 'password', 'last_app_active_at'];
|
|
|
|
protected $hidden = ['password', 'remember_token'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'last_app_active_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
/** The owner reference used to scope every CRM record to this account. */
|
|
public function ownerRef(): string
|
|
{
|
|
return (string) $this->public_id;
|
|
}
|
|
|
|
public function customers(): HasMany
|
|
{
|
|
return $this->hasMany(Customer::class, 'owner_ref', 'public_id');
|
|
}
|
|
|
|
public function leads(): HasMany
|
|
{
|
|
return $this->hasMany(Lead::class, 'owner_ref', 'public_id');
|
|
}
|
|
|
|
public function avatarUrl(): ?string
|
|
{
|
|
$url = trim((string) $this->avatar_url);
|
|
|
|
return $url !== '' ? $url : null;
|
|
}
|
|
}
|