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