repository = $brmagazin; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Project\Project\Repositories\Criteria\BrmagazinResourceCriteria::class); } /** * Display a list of brmagazin. * * @return Response */ public function index(BrmagazinRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Project\Project\Repositories\Presenter\BrmagazinPresenter::class) ->$function(); } $brmagazins = $this->repository->paginate(); return $this->response->setMetaTitle(trans('project::brmagazin.names')) ->view('project::brmagazin.index', true) ->data(compact('brmagazins', 'view')) ->output(); } /** * Display brmagazin. * * @param Request $request * @param Model $brmagazin * * @return Response */ public function show(BrmagazinRequest $request, Brmagazin $brmagazin) { if ($brmagazin->exists) { $view = 'project::brmagazin.show'; } else { $view = 'project::brmagazin.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('project::brmagazin.name')) ->data(compact('brmagazin')) ->view($view, true) ->output(); } /** * Show the form for creating a new brmagazin. * * @param Request $request * * @return Response */ public function create(BrmagazinRequest $request) { $brmagazin = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('project::brmagazin.name')) ->view('project::brmagazin.create', true) ->data(compact('brmagazin')) ->output(); } /** * Create new brmagazin. * * @param Request $request * * @return Response */ public function store(BrmagazinRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $brmagazin = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('project::brmagazin.name')])) ->code(204) ->status('success') ->url(guard_url('project/brmagazin/' . $brmagazin->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/project/brmagazin')) ->redirect(); } } /** * Show brmagazin for editing. * * @param Request $request * @param Model $brmagazin * * @return Response */ public function edit(BrmagazinRequest $request, Brmagazin $brmagazin) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('project::brmagazin.name')) ->view('project::brmagazin.edit', true) ->data(compact('brmagazin')) ->output(); } /** * Update the brmagazin. * * @param Request $request * @param Model $brmagazin * * @return Response */ public function update(BrmagazinRequest $request, Brmagazin $brmagazin) { try { $attributes = $request->all(); $brmagazin->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('project::brmagazin.name')])) ->code(204) ->status('success') ->url(guard_url('project/brmagazin/' . $brmagazin->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('project/brmagazin/' . $brmagazin->getRouteKey())) ->redirect(); } } /** * Remove the brmagazin. * * @param Model $brmagazin * * @return Response */ public function destroy(BrmagazinRequest $request, Brmagazin $brmagazin) { try { $brmagazin->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('project::brmagazin.name')])) ->code(202) ->status('success') ->url(guard_url('project/brmagazin/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('project/brmagazin/' . $brmagazin->getRouteKey())) ->redirect(); } } /** * Remove multiple brmagazin. * * @param Model $brmagazin * * @return Response */ public function delete(BrmagazinRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('project::brmagazin.name')])) ->status("success") ->code(202) ->url(guard_url('project/brmagazin')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/project/brmagazin')) ->redirect(); } } /** * Restore deleted brmagazins. * * @param Model $brmagazin * * @return Response */ public function restore(BrmagazinRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('project::brmagazin.name')])) ->status("success") ->code(202) ->url(guard_url('/project/brmagazin')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/project/brmagazin/')) ->redirect(); } } }