当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::findOrFail方法代码示例

本文整理汇总了PHP中app\Location::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::findOrFail方法的具体用法?PHP Location::findOrFail怎么用?PHP Location::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Location的用法示例。


在下文中一共展示了Location::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * 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!'));
 }
开发者ID:subhadip-sahoo,项目名称:laravel,代码行数:13,代码来源:LocationController.php

示例2: update

 /**
  * 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');
 }
开发者ID:acuccia,项目名称:remote-viewing,代码行数:14,代码来源:LocationsController.php

示例3: update

 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');
 }
开发者ID:romulodl,项目名称:swim,代码行数:7,代码来源:LocationController.php

示例4: update

 /**
  * 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.");
 }
开发者ID:ripixel,项目名称:polefitness,代码行数:14,代码来源:LocationController.php

示例5: show

 /**
  * 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);
 }
开发者ID:shana0440,项目名称:DreamSupport,代码行数:14,代码来源:LocationsController.php

示例6: update

 /**
  * 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");
 }
开发者ID:renciebautista,项目名称:em,代码行数:16,代码来源:LocationsController.php

示例7: getStatistics

 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]);
 }
开发者ID:birgirob,项目名称:TiSDaV,代码行数:12,代码来源:LocationController.php

示例8: generateAddress

 /**
  * 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 . " ) ";
 }
开发者ID:Jemok,项目名称:locate,代码行数:25,代码来源:LocationsRepository.php

示例9: getChartsByLocationId

 public function getChartsByLocationId($id)
 {
     $location = Location::findOrFail($id);
     $charts = $location->charts()->lists('name', 'id');
     return response()->json(['charts' => $charts]);
 }
开发者ID:birgirob,项目名称:TiSDaV,代码行数:6,代码来源:ChartController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $location = Location::findOrFail($id);
     $location->delete();
     return redirect('locations');
 }
开发者ID:Vladimir-Florian,项目名称:Pasu,代码行数:12,代码来源:LocationsController.php

示例11: destroy

 /**
  * 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');
 }
开发者ID:afdalwahyu,项目名称:lnms,代码行数:14,代码来源:LocationsController.php

示例12: destroy

 /**
  * 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]);
 }
开发者ID:soniczhangss,项目名称:Ordering-System,代码行数:46,代码来源:OrdersController.php

示例13: show

 /**
  * 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'));
 }
开发者ID:Vladzor,项目名称:laravelpractice,代码行数:11,代码来源:LocationsController.php

示例14: handleDeleteLocation

 public function handleDeleteLocation()
 {
     // Handle the delete confirmation.
     $id = Input::get('location');
     $location = Location::findOrFail($id);
     $location->delete();
     return Redirect::action('CommonController@locations');
 }
开发者ID:subhadip-sahoo,项目名称:laravel,代码行数:8,代码来源:CommonController.php

示例15: edit

 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]);
 }
开发者ID:gdinko,项目名称:dclassifieds.laravel,代码行数:67,代码来源:LocationController.php


注:本文中的app\Location::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。