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