Exemplo n.º 1
0
 public static function grantStaff($input)
 {
     foreach ($input['staffs'] as $s) {
         $staff = staff::where('userId', $s)->first();
         $grant = 0;
         if (isset($input['grant'])) {
             if (in_array($s, $input['grant'])) {
                 $grant = 1;
             }
         }
         $staff->grant = $grant;
         $staff->save();
     }
 }
Exemplo n.º 2
0
 public static function deleteStaff($staffId)
 {
     $user = user::where('userId', $staffId)->first();
     if ($user->userType == 'doctor') {
         $doctor = doctor::where('userId', $staffId)->first();
         $doctor->delete();
     } else {
         if ($user->userType == 'staff') {
             $staff = staff::where('userId', $staffId)->first();
             $staff->delete();
         }
     }
     $hospitalStaff = hospitalStaff::where('userId', $staffId)->first();
     $hospitalStaff->delete();
     $user->delete();
 }
Exemplo n.º 3
0
 public function addHospitalStaffByAdminStore(Request $request)
 {
     $input = $request->all();
     $user = User::create($input);
     $hospitalStaff = $input;
     $hospitalStaff['userId'] = $user->userId;
     $hospitalStaff = hospitalStaff::create($hospitalStaff);
     if ($input['userType'] == "doctor") {
         $doctor = $input;
         $doctor['userId'] = $user->userId;
         $doctor = doctor::create($doctor);
     }
     if ($input['userType'] == "staff") {
         $staff = $input;
         $staff['userId'] = $user->userId;
         $staff = staff::create($staff);
     }
     // send set password e-mail
     return redirect('/');
 }