repository = $bank_remittance; $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->pushCriteria(new \Payroll\Remittance\Repositories\Criteria\BankRemittanceUserCriteria()); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(BankRemittanceRequest $request) { $bank_remittances = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('remittance::bank_remittance.names')); return $this->theme->of('remittance::user.bank_remittance.index', compact('bank_remittances'))->render(); } /** * Display the specified resource. * * @param Request $request * @param BankRemittance $bank_remittance * * @return Response */ public function show(BankRemittanceRequest $request, BankRemittance $bank_remittance) { Form::populate($bank_remittance); return $this->theme->of('remittance::user.bank_remittance.show', compact('bank_remittance'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(BankRemittanceRequest $request) { $bank_remittance = $this->repository->newInstance([]); Form::populate($bank_remittance); $this->theme->prependTitle(trans('remittance::bank_remittance.names')); return $this->theme->of('remittance::user.bank_remittance.create', compact('bank_remittance'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(BankRemittanceRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $bank_remittance = $this->repository->create($attributes); return redirect(trans_url('/user/remittance/bank_remittance')) -> with('message', trans('messages.success.created', ['Module' => trans('remittance::bank_remittance.name')])) -> with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param BankRemittance $bank_remittance * * @return Response */ public function edit(BankRemittanceRequest $request, BankRemittance $bank_remittance) { Form::populate($bank_remittance); $this->theme->prependTitle(trans('remittance::bank_remittance.names')); return $this->theme->of('remittance::user.bank_remittance.edit', compact('bank_remittance'))->render(); } /** * Update the specified resource. * * @param Request $request * @param BankRemittance $bank_remittance * * @return Response */ public function update(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $this->repository->update($request->all(), $bank_remittance->getRouteKey()); return redirect(trans_url('/user/remittance/bank_remittance')) ->with('message', trans('messages.success.updated', ['Module' => trans('remittance::bank_remittance.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(BankRemittanceRequest $request, BankRemittance $bank_remittance) { try { $this->repository->delete($bank_remittance->getRouteKey()); return redirect(trans_url('/user/remittance/bank_remittance')) ->with('message', trans('messages.success.deleted', ['Module' => trans('remittance::bank_remittance.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }