repository = $journal; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Account\Repositories\Criteria\JournalResourceCriteria::class); } /** * Display a list of journal. * * @return Response */ public function index(JournalRequest $request) { return $this->repository ->setPresenter(\Bixo\Account\Repositories\Presenter\JournalPresenter::class) ->paginate(); } /** * Display journal. * * @param Request $request * @param Model $journal * * @return Response */ public function show(JournalRequest $request, Journal $journal) { return $journal->setPresenter(\Bixo\Account\Repositories\Presenter\JournalListPresenter::class); ; } /** * Create new journal. * * @param Request $request * * @return Response */ public function store(JournalRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('account::journal.name')]); $code = 204; $status = 'success'; $url = guard_url('account/journal/' . $journal->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('account/journal'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the journal. * * @param Request $request * @param Model $journal * * @return Response */ public function update(JournalRequest $request, Journal $journal) { try { $data = $request->all(); $journal->update($data); $message = trans('messages.success.updated', ['Module' => trans('account::journal.name')]); $code = 204; $status = 'success'; $url = guard_url('account/journal/' . $journal->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('account/journal/' . $journal->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the journal. * * @param Model $journal * * @return Response */ public function destroy(JournalRequest $request, Journal $journal) { try { $journal->delete(); $message = trans('messages.success.deleted', ['Module' => trans('account::journal.name')]); $code = 202; $status = 'success'; $url = guard_url('account/journal/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('account/journal/' . $journal->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }