form = LeadForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('litecms.lead.modules'), 'lead', guard_url('lead')); } /** * Display a list of lead. * * @return Response */ public function index(LeadResourceRequest $request) { $request = $request->all(); $page = LeadActions::run('paginate', $request); $data = new LeadsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('lead::lead.names')) ->view('lead::lead.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display lead. * * @param Request $request * @param Model $lead * * @return Response */ public function show(LeadResourceRequest $request, Lead $model) { $form = $this->form; $modules = $this->modules; $data = new LeadResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('lead::lead.name')) ->data(compact('data', 'form', 'modules')) ->view('lead::lead.show') ->output(); } /** * Show the form for creating a new lead. * * @param Request $request * * @return Response */ public function create(LeadResourceRequest $request, Lead $model) { $form = $this->form; $modules = $this->modules; $data = new LeadResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('lead::lead.name')) ->view('lead::lead.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new lead. * * @param Request $request * * @return Response */ public function store(LeadResourceRequest $request, Lead $model) { try { $request = $request->all(); $model = LeadAction::run('store', $model, $request); $data = new LeadResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('lead::lead.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('lead/lead/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/lead/lead')) ->redirect(); } } /** * Show lead for editing. * * @param Request $request * @param Model $lead * * @return Response */ public function edit(LeadResourceRequest $request, Lead $model) { $form = $this->form; $modules = $this->modules; $data = new LeadResource($model); // return view('lead::lead.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('lead::lead.name')) ->view('lead::lead.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the lead. * * @param Request $request * @param Model $lead * * @return Response */ public function update(LeadResourceRequest $request, Lead $model) { try { $request = $request->all(); $model = LeadAction::run('update', $model, $request); $data = new LeadResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('lead::lead.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('lead/lead/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead/lead/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the lead. * * @param Model $lead * * @return Response */ public function destroy(LeadResourceRequest $request, Lead $model) { try { $request = $request->all(); $model = LeadAction::run('destroy', $model, $request); $data = new LeadResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('lead::lead.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('lead/lead/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead/lead/' . $model->getRouteKey())) ->redirect(); } } }