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


PHP Location::findOrFail方法代码示例

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


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

示例1: handleDelete

 public function handleDelete()
 {
     $id = Input::get('location');
     $location = Location::findOrFail($id);
     $location->delete();
     return Redirect::action('LocationController@showList');
 }
开发者ID:Abenaman,项目名称:ggc-talk,代码行数:7,代码来源:LocationController.php

示例2: update

 /**
  * Update the specified location in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $location = Location::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Location::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $location->update($data);
     return Redirect::route('locations.index');
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:16,代码来源:LocationsController.php

示例3: update

 /**
  * Update the specified location in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $location = Location::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Location::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $location->name = Input::get('name');
     $location->description = Input::get('description');
     $location->update();
     return Redirect::route('locations.index')->withFlashMessage('Store has been successfully updated!');
 }
开发者ID:arapmelly,项目名称:xaraerp,代码行数:18,代码来源:LocationsController.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $rules = array('location_name' => 'required|min:2|unique:locations,location_name,' . $id, 'location_charge' => 'required|numeric');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $s = Location::findOrFail($id);
         $s->location_name = Input::get('location_name');
         $s->location_charge = Input::get('location_charge');
         $s->save();
         return Redirect::to('locations')->with('success', 'Location Updated Successfully');
     } else {
         return Redirect::to('locations/' . $id . '/edit')->withErrors($validator)->withInput();
     }
 }
开发者ID:x4rMa,项目名称:Vehicle-Inspection-System,代码行数:20,代码来源:LocationController.php

示例5: store

 /**
  * Store a newly created order in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validation = array('customer' => 'required', 'date' => 'required');
     $validator = Validator::make(Input::all(), $validation);
     if ($validator->fails()) {
         return Redirect::to('orders/create')->withErrors($validator);
     } else {
         $postorder = Input::all();
         $data = array('customer' => $postorder['customer'], 'date' => $postorder['date'], 'total_amount' => $postorder['total_amount'], 'discount' => $postorder['discount'], 'payable_amount' => $postorder['payable_amount'], 'payment' => $postorder['payment'], 'balance' => $postorder['balance']);
         $id = DB::table('orders')->insertGetId($data);
         for ($i = 0; $i < count($postorder['product_id']); $i++) {
             $data_detail = array('product_id' => $postorder['product_id'][$i], 'item' => $postorder['item'][$i], 'quantity' => $postorder['quantity'][$i], 'price' => $postorder['price'][$i], 'amount_charged' => $postorder['amount_charged'][$i], 'Order_id' => $id);
             DB::table('order_details')->insert($data_detail);
             $date = $postorder['date'];
             $location = Location::findOrFail($postorder['location']);
             foreach ($data_detail as $item) {
                 $it = Item::findOrFail($postorder['item'][$i]);
                 $quantity = $postorder['quantity'][$i];
                 Stock::removeStock($it, $location, $quantity, $date);
             }
         }
         return Redirect::route('orders.index')->with('success', 'Item Successfully Added');
     }
 }
开发者ID:kenkode,项目名称:gasexpress,代码行数:29,代码来源:OrdersController.php

示例6: validateAndSave

 public function validateAndSave($event, $location)
 {
     try {
         $uploads_directory = 'images/uploads/';
         if (Input::hasFile('event_image')) {
             $filename = Input::file('event_image')->getClientOriginalName();
             $event->event_image = Input::file('event_image')->move($uploads_directory, $filename);
         }
         if (Input::get('location') == '-1') {
             $location->location_name = Input::get('location_name');
             $location->location_street = Input::get('location_street');
             $location->location_city = Input::get('location_city');
             $location->location_state = Input::get('location_state');
             $location->location_zip = Input::get('location_zip');
             $location->saveOrFail();
         } else {
             $location = Location::findOrFail(Input::get('location'));
         }
         $event->start_time = Input::get('start_time');
         $event->end_time = Input::get('end_time');
         $event->event_name = Input::get('event_name');
         $event->description = Input::get('description');
         $event->cost = Input::get('cost');
         $event->location_id = $location->id;
         $event->creator_id = Auth::id();
         $event->saveOrFail();
         if (Request::wantsJson()) {
             return Response::json(array('Status' => 'Request Succeeded'));
         } else {
             Session::flash('successMessage', 'Your event has been successfully saved.');
             return Redirect::action('CalendarEventsController@show', array($event->id));
         }
     } catch (Watson\Validating\ValidationException $e) {
         Session::flash('errorMessage', 'Ohh no! Something went wrong. You should be seeing some errors down below.');
         Log::info('Validator failed', Input::all());
         return Redirect::back()->withInput()->withErrors($e->getErrors());
     }
 }
开发者ID:Bare-Bones-Events,项目名称:Event-Planner,代码行数:38,代码来源:CalendarEventsController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $location = $this->location->findOrFail($id);
     return View::make('admin.locations.show', compact('location'));
 }
开发者ID:jacobDaeHyung,项目名称:Laravel-Real-Estate-Manager,代码行数:11,代码来源:LocationsController.php

示例8: getAddress

 public function getAddress(CalendarEvent $event)
 {
     $location = Location::findOrFail($event->location_id);
     return Response::json($location);
 }
开发者ID:C-a-p-s-t-o-n-e,项目名称:capstone.dev,代码行数:5,代码来源:CalendarEventsController.php

示例9: validateAndSave

 public function validateAndSave($event, $location)
 {
     try {
         if (Input::get('location_dropdown') == '-1') {
             $location->title = Input::get('location');
             $location->address = Input::get('address');
             $location->city = Input::get('city');
             $location->state = Input::get('state');
             $location->zip = Input::get('zip');
             $location->saveOrFail();
         } else {
             $location = Location::findOrFail(Input::get('location_dropdown'));
         }
         $game = Game::firstOrCreate(array("device" => Input::get('console'), "genre" => Input::get('genre'), "game_title" => Input::get('game')));
         $event->start_time = Input::get('start_time');
         $event->end_time = Input::get('end_time');
         $event->title = Input::get('title');
         $event->description = Input::get('description');
         $event->price = Input::get('price');
         $event->location_id = $location->id;
         $event->game_id = $game->id;
         $event->user_id = Auth::id();
         $event->saveOrFail();
         if (Request::wantsJson()) {
             return Response::json(array('Status' => 'Request Succeeded'));
         } else {
             Session::flash('successMessage', 'Your event has been successfully saved.');
             return Redirect::action('CalendarEventsController@show', array($event->id));
         }
     } catch (Watson\Validating\ValidationException $e) {
         Session::flash('errorMessage', 'Ohh no! Something went wrong. You should be seeing some errors down below.');
         Log::info('Validation failed', Input::all());
         return Redirect::back()->withInput()->withErrors($e->getErrors());
     }
 }
开发者ID:BobFromAccounting,项目名称:events.dev,代码行数:35,代码来源:CalendarEventsController.php

示例10: update

 /**
  * Update the specified calendarevent in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $event = GameEvent::findOrFail($id);
     $location = Location::findOrFail($event->location_id);
     if (!$event) {
         App::abort(404);
     }
     return $this->validateAndSave($event, $location);
 }
开发者ID:Wanna-Play,项目名称:Wanna-Play,代码行数:15,代码来源:GameEventsController.php


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