public function handleDelete() { $id = Input::get('location'); $location = Location::findOrFail($id); $location->delete(); return Redirect::action('LocationController@showList'); }
/** * 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'); }
/** * 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!'); }
/** * 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(); } }
/** * 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'); } }
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()); } }
/** * 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')); }
public function getAddress(CalendarEvent $event) { $location = Location::findOrFail($event->location_id); return Response::json($location); }
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()); } }
/** * 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); }