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