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