form = AppPermissionForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('litecms.app.modules'), 'app', guard_url('app')); } /** * Display a list of app_permission. * * @return Response */ public function index(AppPermissionRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $page = AppPermission::pushScope(new RequestScope()) ->pushScope(new AppPermissionResourceScope()) ->simplePaginate($pageLimit); $data = new AppPermissionsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('app::app_permission.names')) ->view('app::app_permission.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display app_permission. * * @param Request $request * @param Model $app_permission * * @return Response */ public function show(AppPermissionRequest $request, AppPermission $model) { $form = $this->form; $modules = $this->modules; $data = new AppPermissionResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('app::app_permission.name')) ->data(compact('data', 'form', 'modules')) ->view('app::app_permission.show') ->output(); } /** * Show the form for creating a new app_permission. * * @param Request $request * * @return Response */ public function create(AppPermissionRequest $request, AppPermission $model) { $form = $this->form; $modules = $this->modules; $data = new AppPermissionResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('app::app_permission.name')) ->view('app::app_permission.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new app_permission. * * @param Request $request * * @return Response */ public function store(AppPermissionRequest $request, AppPermission $model) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $model = $model->create($attributes); $data = new AppPermissionResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('app::app_permission.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('app/app_permission/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/app/app_permission')) ->redirect(); } } /** * Show app_permission for editing. * * @param Request $request * @param Model $app_permission * * @return Response */ public function edit(AppPermissionRequest $request, AppPermission $model) { $form = $this->form; $modules = $this->modules; $data = new AppPermissionResource($model); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('app::app_permission.name')) ->view('app::app_permission.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the app_permission. * * @param Request $request * @param Model $app_permission * * @return Response */ public function update(AppPermissionRequest $request, AppPermission $model) { try { $attributes = $request->all(); $model = $model->update($attributes); $data = new AppPermissionResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('app::app_permission.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('app/app_permission/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('app/app_permission/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the app_permission. * * @param Model $app_permission * * @return Response */ public function destroy(AppPermissionRequest $request, AppPermission $model) { try { $model->delete(); $data = new AppPermissionResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('app::app_permission.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('app/app_permission/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('app/app_permission/' . $model->getRouteKey())) ->redirect(); } } }