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