repository = $bank_remittance; parent::__construct(); } /** * Display a list of bank_remittance. * * @return json */ public function index(BankRemittanceRequest $request) { $bank_remittances = $this->repository ->setPresenter('\\Payroll\\Remittance\\Repositories\\Presenter\\BankRemittanceListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->all(); $bank_remittances['code'] = 2000; return response()->json($bank_remittances) ->setStatusCode(200, 'INDEX_SUCCESS'); } /** * Display bank_remittance. * * @param Request $request * @param Model BankRemittance * * @return Json */ public function show(BankRemittanceRequest $request, BankRemittance $bank_remittance) { $bank_remittance = $bank_remittance->presenter(); $bank_remittance['code'] = 2001; return response()->json($bank_remittance) ->setStatusCode(200, 'SHOW_SUCCESS');; } /** * Show the form for creating a new bank_remittance. * * @param Request $request * * @return json */ public function create(BankRemittanceRequest $request, BankRemittance $bank_remittance) { $bank_remittance = $bank_remittance->presenter(); $bank_remittance['code'] = 2002; return response()->json($bank_remittance) ->setStatusCode(200, 'CREATE_SUCCESS'); } /** * Create new bank_remittance. * * @param Request $request * * @return json */ public function store(BankRemittanceRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.api'); $bank_remittance = $this->repository->create($attributes); $bank_remittance = $bank_remittance->presenter(); $bank_remittance['code'] = 2004; return response()->json($bank_remittance) ->setStatusCode(201, 'STORE_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4004, ])->setStatusCode(400, 'STORE_ERROR'); } } /** * Show bank_remittance for editing. * * @param Request $request * @param Model $bank_remittance * * @return json */ public function edit(BankRemittanceRequest $request, BankRemittance $bank_remittance) { $bank_remittance = $bank_remittance->presenter(); $bank_remittance['code'] = 2003; return response()-> json($bank_remittance) ->setStatusCode(200, 'EDIT_SUCCESS');; } /** * Update the bank_remittance. * * @param Request $request * @param Model $bank_remittance * * @return json */ public function update(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $attributes = $request->all(); $bank_remittance->update($attributes); $bank_remittance = $bank_remittance->presenter(); $bank_remittance['code'] = 2005; return response()->json($bank_remittance) ->setStatusCode(201, 'UPDATE_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4005, ])->setStatusCode(400, 'UPDATE_ERROR'); } } /** * Remove the bank_remittance. * * @param Request $request * @param Model $bank_remittance * * @return json */ public function destroy(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $t = $bank_remittance->delete(); return response()->json([ 'message' => trans('messages.success.delete', ['Module' => trans('remittance::bank_remittance.name')]), 'code' => 2006 ])->setStatusCode(202, 'DESTROY_SUCCESS'); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 4006, ])->setStatusCode(400, 'DESTROY_ERROR'); } } }