repository = $slide; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Research\Slide\Repositories\Criteria\SlideResourceCriteria::class); } /** * Display a list of slide. * * @return Response */ public function index(SlideRequest $request) { return $this->repository ->setPresenter(\Research\Slide\Repositories\Presenter\SlidePresenter::class) ->paginate(); } /** * Display slide. * * @param Request $request * @param Model $slide * * @return Response */ public function show(SlideRequest $request, Slide $slide) { return $slide->setPresenter(\Research\Slide\Repositories\Presenter\SlideListPresenter::class); ; } /** * Create new slide. * * @param Request $request * * @return Response */ public function store(SlideRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('slide::slide.name')]); $code = 204; $status = 'success'; $url = guard_url('slide/slide/' . $slide->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('slide/slide'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the slide. * * @param Request $request * @param Model $slide * * @return Response */ public function update(SlideRequest $request, Slide $slide) { try { $data = $request->all(); $slide->update($data); $message = trans('messages.success.updated', ['Module' => trans('slide::slide.name')]); $code = 204; $status = 'success'; $url = guard_url('slide/slide/' . $slide->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('slide/slide/' . $slide->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the slide. * * @param Model $slide * * @return Response */ public function destroy(SlideRequest $request, Slide $slide) { try { $slide->delete(); $message = trans('messages.success.deleted', ['Module' => trans('slide::slide.name')]); $code = 202; $status = 'success'; $url = guard_url('slide/slide/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('slide/slide/' . $slide->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }