/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $location = Location::findOrFail(Input::get('id'));
     $location->name = Input::get('name');
     $location->save();
     return Response::json(array('success' => 'Location has been updated!'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $location = Location::findOrFail($id);
     $location->update($request->all());
     Session::flash('message', "Location {$id} Updated");
     return redirect()->action('LocationsController@index');
 }
示例#3
0
 public function update(LocationRequest $request, $id)
 {
     $location = \App\Location::findOrFail($id);
     $location->update($request->all());
     \Session::flash('flash_message', 'Location has been updated.');
     return redirect('locations');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(LocationRequest $request, $id)
 {
     $location = Location::findOrFail($id);
     $location->fill($request->all());
     $location->save();
     return Redirect::back()->with("good", "Successfully updated location.");
 }
 /**
  * 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);
 }
示例#6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $location = Location::findOrFail($id);
     $this->validate($request, ['location' => 'required|max:100']);
     $location->location = $request->location;
     $location->update();
     Session::flash('flash_message', 'Location successfully updated!');
     return redirect()->route("location.index");
 }
示例#7
0
 public function getStatistics($id)
 {
     $loc = Location::findOrFail($id);
     $charts = $loc->charts;
     $stats = [];
     foreach ($charts as $c) {
         $stats[$c['id']]['chartName'] = $c->name;
         $stats[$c['id']]['chartUnit'] = $c->unit->symbol;
         $stats[$c['id']]['stats'] = ChartStatistics::getChartStats($c['id']);
     }
     return response()->json(['allStats' => $stats]);
 }
示例#8
0
 /**
  * Generate an address for a location
  * @param $location
  * @return string
  */
 private function generateAddress($location)
 {
     $locationName = $location->locationKeyCode;
     $locationId = $location->id;
     $location = $this->location->findOrFail($locationId);
     $levelId = $location->level_id;
     $level = $this->level_building->findOrFail($levelId);
     $levelName = $level->levelName;
     $building_id = $level->building_id;
     $building = $this->building->findOrFail($building_id);
     $buildingName = $building->buildingKeyCode;
     $street_id = $building->street_id;
     $street = $this->street->findOrFail($street_id);
     $streetName = $street->streetKeyCode;
     $agent_id = $street->agent_id;
     $this->agent_id = $agent_id;
     //$agent = $this->agent->findOrFail($agent_id);
     $agentName = \App\Agent::where('user_id', '=', $agent_id)->first()->agentName;
     return $buildingName . $levelName . $locationName . "-" . $streetName . " ( " . $agentName . " ) ";
 }
示例#9
0
 public function getChartsByLocationId($id)
 {
     $location = Location::findOrFail($id);
     $charts = $location->charts()->lists('name', 'id');
     return response()->json(['charts' => $charts]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $location = Location::findOrFail($id);
     $location->delete();
     return redirect('locations');
 }
示例#11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $location = \App\Location::findOrFail($id);
     \Session::flash('flash_message', 'location ' . $location->name . ' deleted.');
     // delete
     $location->delete();
     return redirect('locations');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request)
 {
     $rp_arr = [];
     $user = \Auth::user();
     if ($user->role->name != ('admin' or 'root')) {
         // Permission denied
     } else {
         $data = $request->json()->get('data');
         $lookUpArr = [];
         for ($i = 0; $i < count($data); $i++) {
             /*$from = Carbon::parse($data[$i]['from']);
                             $to = Carbon::parse($data[$i]['to']);
                             $location_id = \App\Location::where('name', $data[$i]['location'])->first()['id'];
             
                             \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->delete();*/
             $id = $data[$i]['id'];
             $order = \App\Order::findOrFail($id);
             array_push($lookUpArr, ['from' => $order->from, 'to' => $order->to, 'location_id' => $order->location_id]);
             \App\Order::destroy($id);
         }
         $lookUpArr = array_unique($lookUpArr, SORT_REGULAR);
         foreach ($lookUpArr as $value) {
             $from = Carbon::parse($value['from']);
             $to = Carbon::parse($value['to']);
             $location_id = $value['location_id'];
             $num_of_ordered = \App\Order::where('from', $from)->where('to', $to)->where('location_id', $location_id)->count();
             $allowance = \App\Location::findOrFail($location_id)->capacity;
             if ($num_of_ordered < $allowance) {
                 if ($num_of_ordered == 0) {
                     array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '-1']);
                 } else {
                     array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '1']);
                 }
             } else {
                 array_push($rp_arr, ['from' => $value['from'], 'to' => $value['to'], 'status' => '0']);
             }
         }
     }
     return response()->json(['data' => $rp_arr]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $location = Location::findOrFail($id);
     return view('locations.show', compact('location'));
 }
示例#14
0
 public function handleDeleteLocation()
 {
     // Handle the delete confirmation.
     $id = Input::get('location');
     $location = Location::findOrFail($id);
     $location->delete();
     return Redirect::action('CommonController@locations');
 }
 public function edit(Request $request)
 {
     $allLocationHierarhy = $this->location->getAllHierarhy(null, 0, 0);
     $id = 0;
     if (isset($request->id)) {
         $id = $request->id;
     }
     $modelData = new \stdClass();
     if ($id > 0) {
         try {
             $modelData = Location::findOrFail($id);
         } catch (ModelNotFoundException $e) {
             session()->flash('message', trans('admin_common.Invalid Location'));
             return redirect(url('admin/location'));
         }
     }
     $lid = 0;
     if (isset($modelData->location_parent_id) && $modelData->location_parent_id > 0) {
         $lid = $modelData->location_parent_id;
     }
     /**
      * form is submitted check values and save if needed
      */
     if ($request->isMethod('post')) {
         /**
          * validate data
          */
         $rules = ['location_name' => 'required|max:255', 'location_slug' => 'required|max:255|unique:location,location_slug'];
         if (isset($modelData->location_id)) {
             $rules['location_slug'] = 'required|max:255|unique:location,location_slug,' . $modelData->location_id . ',location_id';
         }
         $validator = Validator::make($request->all(), $rules);
         if ($validator->fails()) {
             $this->throwValidationException($request, $validator);
         }
         /**
          * get data from form
          */
         $data = $request->all();
         /**
          * save data if validated
          */
         if (isset($data['location_active'])) {
             $data['location_active'] = 1;
         } else {
             $data['location_active'] = 0;
         }
         if ($data['location_parent_id'] == 0) {
             unset($data['location_parent_id']);
         }
         /**
          * save or update
          */
         if (!isset($modelData->location_id)) {
             Location::create($data);
         } else {
             $modelData->update($data);
         }
         /**
          * clear cache, set message, redirect to list
          */
         Cache::flush();
         session()->flash('message', trans('admin_common.Location saved'));
         return redirect(url('admin/location'));
     }
     return view('admin.location.location_edit', ['l' => $allLocationHierarhy, 'modelData' => $modelData, 'lid' => $lid]);
 }