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