*/ protected $fillable = [ 'name', 'email', 'no_telp', 'password', 'role_id', // Added role_id to the fillable attributes ]; /** * 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', ]; /** * Get the role associated with the user. */ public function role() { return $this->belongsTo(Role::class); // Defines the relationship to the Role model } /** * Get the alert setting associated with the user. */ public function alertSetting() { return $this->hasOne(UserAlertSetting::class); } /** * Get the notifications for the user. */ public function notifications() { return $this->hasMany(UserNotification::class); } /** * Get unread notifications for the user. */ public function unreadNotifications() { return $this->notifications()->unread(); } /** * Get read notifications for the user. */ public function readNotifications() { return $this->notifications()->read(); } }