// Check User Type if($user->user_type == 'manager'){ $properties = Property::where('property_manager', $user->username)->get(); $overduePayments = Property::where('property_manager', $user->username)->where('property_last_payment_date', '<', now())->get(); $rentRecords = RentRecord::with(['property', 'tenant', 'recorder']) ->whereHas('property', function ($query) use ($user) { $query->where('property_manager', $user->username); }) ->get(); }else{ $properties = Property::all(); $rentRecords = RentRecord::with(['property', 'tenant', 'recorder'])->get(); $overduePayments = Property::where('property_last_payment_date', '<', now())->get(); } // Redirecting based on user type if($user->user_type == 'admin'){ // SUCCESS return response()->json([ "status" => true, "redirect" => url('properties/admin/dashboard/index'), "message" => "System settings updated successfully.", ]); }else if($user->user_type == 'manager'){ // SUCCESS return response()->json([ "status" => true, "redirect" => url('properties/manager/dashboard/index'), "message" => "Password updated successfully.", ]); }else{ // SUCCESS return response()->json([ "status" => true, "redirect" => url('properties/tenant/dashboard/index'), "message" => "Password updated successfully.", ]); }