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