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