form = GalleriesForm::setAttributes()->toArray(); $this->modules = $this->modules(config('bmc.staff.modules'), 'staff', guard_url('staff')); $this->repository = $galleries; } /** * Display a list of galleries. * * @return Response */ public function index(GalleriesRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(GalleriesResourceFilter::class) ->setPresenter(GalleriesListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('staff::galleries.names')) ->view('staff::galleries.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display galleries. * * @param Request $request * @param Model $galleries * * @return Response */ public function show(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('staff::galleries.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('staff::galleries.show') ->output(); } /** * Show the form for creating a new galleries. * * @param Request $request *x * @return Response */ public function create(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('staff::galleries.name')) ->view('staff::galleries.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new galleries. * * @param Request $request * * @return Response */ public function store(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.created', ['Module' => trans('staff::galleries.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('staff/galleries/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/staff/galleries')) ->redirect(); } } /** * Show galleries for editing. * * @param Request $request * @param Model $galleries * * @return Response */ public function edit(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('staff::galleries.name')) ->view('staff::galleries.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the galleries. * * @param Request $request * @param Model $galleries * * @return Response */ public function update(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('staff::galleries.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('staff/galleries/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('staff/galleries/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the galleries. * * @param Model $galleries * * @return Response */ public function destroy(GalleriesRequest $request, GalleriesRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('staff::galleries.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('staff/galleries/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('staff/galleries/' . $repository->getRouteKey())) ->redirect(); } } }