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