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