repository = $lead_capture_page; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\LeadCapturePage\Repositories\Criteria\LeadCapturePageResourceCriteria::class); } /** * Display a list of lead_capture_page. * * @return Response */ public function index(LeadCapturePageRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\LeadCapturePage\Repositories\Presenter\LeadCapturePagePresenter::class) ->$function(); } $lead_capture_pages = $this->repository->paginate(); return $this->response->title(trans('lead_capture_page::lead_capture_page.names')) ->view('lead_capture_page::lead_capture_page.index', true) ->data(compact('lead_capture_pages')) ->output(); } /** * Display lead_capture_page. * * @param Request $request * @param Model $lead_capture_page * * @return Response */ public function show(LeadCapturePageRequest $request, LeadCapturePage $lead_capture_page) { if ($lead_capture_page->exists) { $view = 'lead_capture_page::lead_capture_page.show'; } else { $view = 'lead_capture_page::lead_capture_page.new'; } return $this->response->title(trans('app.view') . ' ' . trans('lead_capture_page::lead_capture_page.name')) ->data(compact('lead_capture_page')) ->view($view, true) ->output(); } /** * Show the form for creating a new lead_capture_page. * * @param Request $request * * @return Response */ public function create(LeadCapturePageRequest $request) { $lead_capture_page = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('lead_capture_page::lead_capture_page.name')) ->view('lead_capture_page::lead_capture_page.create', true) ->data(compact('lead_capture_page')) ->output(); } /** * Create new lead_capture_page. * * @param Request $request * * @return Response */ public function store(LeadCapturePageRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $lead_capture_page = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('lead_capture_page::lead_capture_page.name')])) ->code(204) ->status('success') ->url(guard_url('lead_capture_page/lead_capture_page/' . $lead_capture_page->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/lead_capture_page/lead_capture_page')) ->redirect(); } } /** * Show lead_capture_page for editing. * * @param Request $request * @param Model $lead_capture_page * * @return Response */ public function edit(LeadCapturePageRequest $request, LeadCapturePage $lead_capture_page) { return $this->response->title(trans('app.edit') . ' ' . trans('lead_capture_page::lead_capture_page.name')) ->view('lead_capture_page::lead_capture_page.edit', true) ->data(compact('lead_capture_page')) ->output(); } /** * Update the lead_capture_page. * * @param Request $request * @param Model $lead_capture_page * * @return Response */ public function update(LeadCapturePageRequest $request, LeadCapturePage $lead_capture_page) { try { $attributes = $request->all(); $lead_capture_page->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('lead_capture_page::lead_capture_page.name')])) ->code(204) ->status('success') ->url(guard_url('lead_capture_page/lead_capture_page/' . $lead_capture_page->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead_capture_page/lead_capture_page/' . $lead_capture_page->getRouteKey())) ->redirect(); } } /** * Remove the lead_capture_page. * * @param Model $lead_capture_page * * @return Response */ public function destroy(LeadCapturePageRequest $request, LeadCapturePage $lead_capture_page) { try { $lead_capture_page->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('lead_capture_page::lead_capture_page.name')])) ->code(202) ->status('success') ->url(guard_url('lead_capture_page/lead_capture_page/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lead_capture_page/lead_capture_page/' . $lead_capture_page->getRouteKey())) ->redirect(); } } /** * Remove multiple lead_capture_page. * * @param Model $lead_capture_page * * @return Response */ public function delete(LeadCapturePageRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('lead_capture_page::lead_capture_page.name')])) ->status("success") ->code(202) ->url(guard_url('lead_capture_page/lead_capture_page')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/lead_capture_page/lead_capture_page')) ->redirect(); } } /** * Restore deleted lead_capture_pages. * * @param Model $lead_capture_page * * @return Response */ public function restore(LeadCapturePageRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('lead_capture_page::lead_capture_page.name')])) ->status("success") ->code(202) ->url(guard_url('/lead_capture_page/lead_capture_page')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/lead_capture_page/lead_capture_page/')) ->redirect(); } } }