本文整理汇总了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');
}
示例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');
}
示例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!');
}
示例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();
}
}
示例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');
}
}
示例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());
}
}
示例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'));
}
示例8: getAddress
public function getAddress(CalendarEvent $event)
{
$location = Location::findOrFail($event->location_id);
return Response::json($location);
}
示例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());
}
}
示例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);
}