Ejemplo n.º 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $location = Location::findOrFail($id);
     $weathers = Weather::get($location->name);
     $hospitals = Hospital::where('address', 'LIKE', "%{$location->name}%")->get();
     $request = ['weathers' => $weathers, 'hospitals' => $hospitals];
     return json_encode($request);
 }
Ejemplo n.º 2
0
 public function fuzzyQuery(Request $request)
 {
     $this->validate($request, ['keyword' => 'required|max:255']);
     $keyword = $request->get('keyword');
     $hospitals = Hospital::where('hospital_name', 'like', "%{$keyword}%")->orwhere('city', 'like', "%{$keyword}%")->orwhere('hospital_level', 'like', "%{$keyword}%")->orwhere('description', 'like', "%{$keyword}%")->get();
     $departments = Department::where('department_name', 'like', "%{$keyword}%")->orwhere('department_description', 'like', "%{$keyword}%")->get();
     $doctors = Doctor::where('doctor_name', 'like', "%{$keyword}%")->orwhere('doctor_level', 'like', "%{$keyword}%")->orwhere('doctor_description', 'like', "%{$keyword}%")->get();
     $response = ['hospitals' => $hospitals, 'department' => $departments, 'doctors' => $doctors];
     return json_encode($response);
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('hospitals')->delete();
     $hospital = new Hospital(['name' => 'Provo Family', 'address' => '1528 Freedom Blvd 200 W']);
     $hospital->save();
 }
Ejemplo n.º 4
0
 public function editInfo(Request $request)
 {
     $hid = $request->get('id');
     $hosp = Hospital::find($hid);
     if (is_null($hosp)) {
         return "Hospital id not found";
     }
     $n_name = $request->get('hospital_name');
     $n_city = $request->get('city');
     $n_image = $request->get('image');
     $n_hlevel = $request->get('hospital_level');
     $n_ownership = $request->get('ownership');
     $n_desc = $request->get('description');
     if (!is_null($n_name)) {
         $hosp->hospital_name = $n_name;
     }
     if (!is_null($n_city)) {
         $hosp->city = $n_city;
     }
     if (!is_null($n_image)) {
         $hosp->image = $n_image;
     }
     if (!is_null($n_hlevel)) {
         $hosp->ownership = $n_ownership;
     }
     if (!is_null($n_desc)) {
         $hosp->description = $n_desc;
     }
     $success = $hosp->save();
     return $success ? "true" : "false";
 }
 /**
  * 打印预约单
  *
  * @param Request $request
  * @param Registration $registration
  */
 public function printInfo(Request $request, Registration $registration)
 {
     $user = $request->user();
     if ($user->id != $registration->user_id) {
         return response()->json(['status' => 1, 'message' => '无权限']);
     }
     if ($registration->is_paid == 1) {
         if ($registration->deals()->count() != 1) {
             return response()->json(['status' => 4, 'message' => '数据异常']);
         }
         $schedule = Schedule::find($registration->schedule_id);
         $doctor = Doctor::find($schedule->doctor_id);
         $department = Department::find($doctor->department_id);
         $hospital = Hospital::find($department->hospital_id);
         $data = array('user_name' => $user->name, 'sex' => $user->sex, 'age' => $user->age, 'doctor' => $doctor->doctor_name, 'doctor_time' => $schedule->doctoring_time, 'doctor_data' => $schedule->doctoring_data, 'department' => $department->department_nam, 'hospital' => $hospital->hospital_name, 'fee' => $registration->fee, 'registration_time' => $registration->created_at);
         return $data;
     } else {
         return response()->json(['status' => 8, 'message' => '未付款,不能打印']);
     }
 }
Ejemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->except('_token');
     //  var_dump($data);
     //  exit();
     $rules = ['name' => 'required', 'email' => 'email|unique:users,email|required', 'password' => 'required|confirmed', 'password_confirmation' => 'required', 'type' => 'required', 'city' => 'required'];
     $message = ['required' => 'The :attribute field is required.', 'unique' => 'Existing Mail.', 'confirmed' => 'Confirmed Password does not match.'];
     $validator = Validator::make($data, $rules, $message);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::route('hospitals.create')->withErrors($validator)->withInput();
     }
     $data['password'] = bcrypt($data['password']);
     unset($data['password_confirmation']);
     $file = $data['filefield'];
     $extension = $file->getClientOriginalExtension();
     $filename = $file->getFilename() . '.' . $extension;
     //Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));
     $destination = 'images/';
     $file->move($destination, $filename);
     $users = new User();
     $users->name = $data["name"];
     $users->email = $data['email'];
     $users->password = $data['password'];
     $users->role_id = 2;
     $users->mime = $file->getClientMimeType();
     $users->photo = $file->getFilename() . '.' . $extension;
     $users->save();
     //$g = User::whereRaw('id = (select max(`id`) from users)')->get();
     $uid = DB::table('users')->where('id', DB::raw("(select max(`id`) from users)"))->get();
     foreach ($uid as $did) {
         $userid = $did->id;
     }
     $hospitals = new Hospital();
     $hospitals->hospital_name = $data["name"];
     $hospitals->hospital_address = $data["address"];
     $hospitals->hospital_ph = $data['phone'];
     $hospitals->hospital_email = $data['email'];
     $hospitals->hospital_website = $data['website'];
     $hospitals->hospital_type = $data['type'];
     $hospitals->city_id = $data['city'];
     $hospitals->about = $data['about'];
     $hospitals->direction = $data['direction'];
     $hospitals->location = $data['location'];
     $hospitals->mime = $file->getClientMimeType();
     $hospitals->photo = $file->getFilename() . '.' . $extension;
     $hospitals->user_id = $userid;
     $hospitals->save();
     $hid = DB::table('hospitals')->where('id', DB::raw("(select max(`id`) from hospitals)"))->get();
     foreach ($hid as $hd) {
         $hospitalsid = $hd->id;
     }
     $facility = DB::select(DB::raw("select * from facilities"));
     foreach ($facility as $f) {
         if (isset($data[$f->id])) {
             $fac = new Facilityjunction();
             $fac->hospital_id = $hospitalsid;
             $fac->facilities_id = $data[$f->id];
             $fac->save();
         }
     }
     $allhos = DB::select(DB::raw("select hospitals.*,cities.city_name from hospitals inner join cities on hospitals.city_id=cities.id "));
     return View::make('hospitals.all')->with(compact('allhos'));
 }