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