middleware(function ($request, $next) { $this->form = OrderVehicleForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.cross_trade.modules'), 'cross_trade', guard_url('cross_trade')); return $next($request); }); } /** * Display a list of order_vehicle. * * @return Response */ public function index(OrderVehicleResourceRequest $request) { $request = $request->all(); $page = OrderVehicleActions::run('paginate', $request); $data = new OrderVehiclesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('cross_trade::order_vehicle.names')) ->view('cross_trade::order_vehicle.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display order_vehicle. * * @param Request $request * @param Model $order_vehicle * * @return Response */ public function show(OrderVehicleResourceRequest $request, OrderVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OrderVehicleResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('cross_trade::order_vehicle.name')) ->data(compact('data', 'form', 'modules')) ->view('cross_trade::order_vehicle.show') ->output(); } /** * Show the form for creating a new order_vehicle. * * @param Request $request * * @return Response */ public function create(OrderVehicleResourceRequest $request, OrderVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OrderVehicleResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('cross_trade::order_vehicle.name')) ->view('cross_trade::order_vehicle.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new order_vehicle. * * @param Request $request * * @return Response */ public function store(OrderVehicleResourceRequest $request, OrderVehicle $model) { try { $request = $request->all(); $model = OrderVehicleAction::run('store', $model, $request); $data = new OrderVehicleResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('cross_trade::order_vehicle.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('cross_trade/order_vehicle/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/cross_trade/order_vehicle')) ->redirect(); } } /** * Show order_vehicle for editing. * * @param Request $request * @param Model $order_vehicle * * @return Response */ public function edit(OrderVehicleResourceRequest $request, OrderVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OrderVehicleResource($model); // return view('cross_trade::order_vehicle.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('cross_trade::order_vehicle.name')) ->view('cross_trade::order_vehicle.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the order_vehicle. * * @param Request $request * @param Model $order_vehicle * * @return Response */ public function update(OrderVehicleResourceRequest $request, OrderVehicle $model) { try { $request = $request->all(); $model = OrderVehicleAction::run('update', $model, $request); $data = new OrderVehicleResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('cross_trade::order_vehicle.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('cross_trade/order_vehicle/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('cross_trade/order_vehicle/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the order_vehicle. * * @param Model $order_vehicle * * @return Response */ public function destroy(OrderVehicleResourceRequest $request, OrderVehicle $model) { try { $request = $request->all(); $model = OrderVehicleAction::run('destroy', $model, $request); $data = new OrderVehicleResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('cross_trade::order_vehicle.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('cross_trade/order_vehicle/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('cross_trade/order_vehicle/' . $model->getRouteKey())) ->redirect(); } } }