repository = $gallery; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litepie\Event\Repositories\Criteria\GalleryResourceCriteria::class); } /** * Display a list of gallery. * * @return Response */ public function index(GalleryRequest $request) { return $this->repository ->setPresenter(\Litepie\Event\Repositories\Presenter\GalleryPresenter::class) ->paginate(); } /** * Display gallery. * * @param Request $request * @param Model $gallery * * @return Response */ public function show(GalleryRequest $request, Gallery $gallery) { return $gallery->setPresenter(\Litepie\Event\Repositories\Presenter\GalleryListPresenter::class); ; } /** * Create new gallery. * * @param Request $request * * @return Response */ public function store(GalleryRequest $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('event::gallery.name')]); $code = 204; $status = 'success'; $url = guard_url('event/gallery/' . $gallery->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('event/gallery'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the gallery. * * @param Request $request * @param Model $gallery * * @return Response */ public function update(GalleryRequest $request, Gallery $gallery) { try { $data = $request->all(); $gallery->update($data); $message = trans('messages.success.updated', ['Module' => trans('event::gallery.name')]); $code = 204; $status = 'success'; $url = guard_url('event/gallery/' . $gallery->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('event/gallery/' . $gallery->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the gallery. * * @param Model $gallery * * @return Response */ public function destroy(GalleryRequest $request, Gallery $gallery) { try { $gallery->delete(); $message = trans('messages.success.deleted', ['Module' => trans('event::gallery.name')]); $code = 202; $status = 'success'; $url = guard_url('event/gallery/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('event/gallery/' . $gallery->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); } }