*/ protected $fillable = [ 'username', 'name', 'email', 'password', 'phone', 'avatar', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; /** * Get the login logs for the user. */ public function loginLogs() { return $this->hasMany(\App\Models\UserLoginLog::class); } /** * Get the user's avatar URL. */ public function getAvatarUrlAttribute(): string { if ($this->avatar) { return asset('storage/' . $this->avatar); } return "https://ui-avatars.com/api/?name=" . urlencode($this->name) . "&background=0D8ABC&color=fff"; } }