repository = $bank; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Inventory\Bank\Repositories\Criteria\BankResourceCriteria::class); } /** * Display a list of bank. * * @return Response */ public function index(BankRequest $request) { return $this->repository ->setPresenter(\Inventory\Bank\Repositories\Presenter\BankPresenter::class) ->paginate(); } /** * Display bank. * * @param Request $request * @param Model $bank * * @return Response */ public function show(BankRequest $request, Bank $bank) { return $bank->setPresenter(\Inventory\Bank\Repositories\Presenter\BankListPresenter::class); ; } /** * Create new bank. * * @param Request $request * * @return Response */ public function store(BankRequest $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('bank::bank.name')]); $code = 204; $status = 'success'; $url = guard_url('bank/bank/' . $bank->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('bank/bank'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the bank. * * @param Request $request * @param Model $bank * * @return Response */ public function update(BankRequest $request, Bank $bank) { try { $data = $request->all(); $bank->update($data); $message = trans('messages.success.updated', ['Module' => trans('bank::bank.name')]); $code = 204; $status = 'success'; $url = guard_url('bank/bank/' . $bank->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('bank/bank/' . $bank->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the bank. * * @param Model $bank * * @return Response */ public function destroy(BankRequest $request, Bank $bank) { try { $bank->delete(); $message = trans('messages.success.deleted', ['Module' => trans('bank::bank.name')]); $code = 202; $status = 'success'; $url = guard_url('bank/bank/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('bank/bank/' . $bank->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); } }