middleware(function ($request, $next) { $this->form = OfferUsVehicleForm::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 offer_us_vehicle. * * @return Response */ public function index(OfferUsVehicleResourceRequest $request) { $request = $request->all(); $page = OfferUsVehicleActions::run('paginate', $request); $data = new OfferUsVehiclesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('cross_trade::offer_us_vehicle.names')) ->view('cross_trade::offer_us_vehicle.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display offer_us_vehicle. * * @param Request $request * @param Model $offer_us_vehicle * * @return Response */ public function show(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OfferUsVehicleResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('cross_trade::offer_us_vehicle.name')) ->data(compact('data', 'form', 'modules')) ->view('cross_trade::offer_us_vehicle.show') ->output(); } /** * Show the form for creating a new offer_us_vehicle. * * @param Request $request * * @return Response */ public function create(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OfferUsVehicleResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('cross_trade::offer_us_vehicle.name')) ->view('cross_trade::offer_us_vehicle.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new offer_us_vehicle. * * @param Request $request * * @return Response */ public function store(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { try { $request = $request->all(); $model = OfferUsVehicleAction::run('store', $model, $request); $data = new OfferUsVehicleResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('cross_trade::offer_us_vehicle.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('cross_trade/offer_us_vehicle/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/cross_trade/offer_us_vehicle')) ->redirect(); } } /** * Show offer_us_vehicle for editing. * * @param Request $request * @param Model $offer_us_vehicle * * @return Response */ public function edit(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { $form = $this->form; $modules = $this->modules; $data = new OfferUsVehicleResource($model); // return view('cross_trade::offer_us_vehicle.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('cross_trade::offer_us_vehicle.name')) ->view('cross_trade::offer_us_vehicle.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the offer_us_vehicle. * * @param Request $request * @param Model $offer_us_vehicle * * @return Response */ public function update(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { try { $request = $request->all(); $model = OfferUsVehicleAction::run('update', $model, $request); $data = new OfferUsVehicleResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('cross_trade::offer_us_vehicle.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('cross_trade/offer_us_vehicle/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('cross_trade/offer_us_vehicle/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the offer_us_vehicle. * * @param Model $offer_us_vehicle * * @return Response */ public function destroy(OfferUsVehicleResourceRequest $request, OfferUsVehicle $model) { try { $request = $request->all(); $model = OfferUsVehicleAction::run('destroy', $model, $request); $data = new OfferUsVehicleResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('cross_trade::offer_us_vehicle.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('cross_trade/offer_us_vehicle/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('cross_trade/offer_us_vehicle/' . $model->getRouteKey())) ->redirect(); } } }