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