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