form = LeadSystemForm::setAttributes()->toArray(); $this->modules = $this->modules(config('litecms.lead.modules'), 'lead', guard_url('lead')); $this->repository = $lead_system; } /** * Display a list of lead_system. * * @return Response */ public function index(LeadSystemRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(LeadSystemResourceFilter::class) ->setPresenter(LeadSystemListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('lead::lead_system.names')) ->view('lead::lead_system.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display lead_system. * * @param Request $request * @param Model $lead_system * * @return Response */ public function show(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('lead::lead_system.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('lead::lead_system.show') ->output(); } /** * Show the form for creating a new lead_system. * * @param Request $request *x * @return Response */ public function create(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('lead::lead_system.name')) ->view('lead::lead_system.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new lead_system. * * @param Request $request * * @return Response */ public function store(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.created', ['Module' => trans('lead::lead_system.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('lead/lead_system/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/lead/lead_system')) ->redirect(); } } /** * Show lead_system for editing. * * @param Request $request * @param Model $lead_system * * @return Response */ public function edit(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('lead::lead_system.name')) ->view('lead::lead_system.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the lead_system. * * @param Request $request * @param Model $lead_system * * @return Response */ public function update(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('lead::lead_system.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('lead/lead_system/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead/lead_system/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the lead_system. * * @param Model $lead_system * * @return Response */ public function destroy(LeadSystemRequest $request, LeadSystemRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('lead::lead_system.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('lead/lead_system/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead/lead_system/' . $repository->getRouteKey())) ->redirect(); } } }