webmoney/backend/app/Models/User.php
marcoitaloesp-ai abaf0097c5
feat(profile): perfil completo para SaaS v1.48.0
- Expandir tabela users com campos para SaaS
- Adicionar: first_name, last_name, phone_country_code, phone
- Adicionar: accept_whatsapp, accept_emails, country, timezone, locale
- User Model: accessors fullName e fullPhone
- Profile.jsx: formulário completo com DDI, checkboxes, seletores
- Traduções i18n em ES, PT-BR, EN
- Fase 1 do roadmap SaaS concluída
2025-12-17 10:40:20 +00:00

94 lines
2.1 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable, HasApiTokens;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'first_name',
'last_name',
'email',
'phone_country_code',
'phone',
'accept_whatsapp',
'accept_emails',
'avatar',
'country',
'timezone',
'locale',
'password',
'is_admin',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_admin' => 'boolean',
'accept_whatsapp' => 'boolean',
'accept_emails' => 'boolean',
];
}
/**
* Get full name attribute
*/
public function getFullNameAttribute(): string
{
if ($this->first_name && $this->last_name) {
return "{$this->first_name} {$this->last_name}";
}
return $this->name ?? '';
}
/**
* Get full phone with country code
*/
public function getFullPhoneAttribute(): ?string
{
if ($this->phone_country_code && $this->phone) {
return "{$this->phone_country_code} {$this->phone}";
}
return $this->phone;
}
/**
* Verifica se o usuário é administrador
*/
public function isAdmin(): bool
{
return $this->is_admin === true;
}
}