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