*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'profile_photo', ]; /** * URL foto profil — fallback ke null jika tidak ada */ public function getProfilePhotoUrlAttribute(): ?string { if ($this->profile_photo) { return asset('storage/' . $this->profile_photo); } return null; } /** * Inisial nama untuk avatar fallback */ public function getInitialsAttribute(): string { $words = explode(' ', trim($this->name)); if (count($words) >= 2) { return strtoupper(substr($words[0], 0, 1) . substr($words[1], 0, 1)); } return strtoupper(substr($this->name, 0, 2)); } /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } }