repository = $bank_remittance; parent::__construct(); } /** * Display a list of bank_remittance. * * @return Response */ public function index(BankRemittanceRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('remittance::bank_remittance.names').' :: '); return $this->theme->of('remittance::admin.bank_remittance.index')->render(); } /** * Display a list of bank_remittance. * * @return Response */ public function getJson(BankRemittanceRequest $request) { $pageLimit = $request->input('pageLimit'); $bank_remittances = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Payroll\\Remittance\\Repositories\\Presenter\\BankRemittanceListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $bank_remittances['recordsTotal'] = $bank_remittances['meta']['pagination']['total']; $bank_remittances['recordsFiltered'] = $bank_remittances['meta']['pagination']['total']; $bank_remittances['request'] = $request->all(); return response()->json($bank_remittances, 200); } /** * Display bank_remittance. * * @param Request $request * @param Model $bank_remittance * * @return Response */ public function show(BankRemittanceRequest $request, BankRemittance $bank_remittance) { if (!$bank_remittance->exists) { return response()->view('remittance::admin.bank_remittance.new', compact('bank_remittance')); } Form::populate($bank_remittance); return response()->view('remittance::admin.bank_remittance.show', compact('bank_remittance')); } /** * Show the form for creating a new bank_remittance. * * @param Request $request * * @return Response */ public function create(BankRemittanceRequest $request) { $bank_remittance = $this->repository->newInstance([]); Form::populate($bank_remittance); return response()->view('remittance::admin.bank_remittance.create', compact('bank_remittance')); } /** * Create new bank_remittance. * * @param Request $request * * @return Response */ public function store(BankRemittanceRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $bank_remittance = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('remittance::bank_remittance.name')]), 'code' => 204, 'redirect' => trans_url('/admin/remittance/bank_remittance/'.$bank_remittance->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show bank_remittance for editing. * * @param Request $request * @param Model $bank_remittance * * @return Response */ public function edit(BankRemittanceRequest $request, BankRemittance $bank_remittance) { Form::populate($bank_remittance); return response()->view('remittance::admin.bank_remittance.edit', compact('bank_remittance')); } /** * Update the bank_remittance. * * @param Request $request * @param Model $bank_remittance * * @return Response */ public function update(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $attributes = $request->all(); $bank_remittance->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('remittance::bank_remittance.name')]), 'code' => 204, 'redirect' => trans_url('/admin/remittance/bank_remittance/'.$bank_remittance->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/remittance/bank_remittance/'.$bank_remittance->getRouteKey()), ], 400); } } /** * Remove the bank_remittance. * * @param Model $bank_remittance * * @return Response */ public function destroy(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $t = $bank_remittance->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('remittance::bank_remittance.name')]), 'code' => 202, 'redirect' => trans_url('/admin/remittance/bank_remittance/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/remittance/bank_remittance/'.$bank_remittance->getRouteKey()), ], 400); } } }