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