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