Example #1
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();
 }
Example #2
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('/');
 }
Example #3
0
 public function searchHospitalStaff($url)
 {
     $query = e(Input::get('q', ''));
     if (!$query && $query == '') {
         return Response::json(array(), 400);
     }
     $staff = hospitalStaff::searchHospitalStaff($query)->take(5)->get(array('hospitalStaff.userId', 'name', 'surname'));
     $staff = $this->appendClass($staff, 'staff');
     $staff = $this->appendUrl($staff, $url);
     return Response::json(array('data' => $staff));
 }