repository = $client_order; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Urdtlv\Clientpay\Repositories\Criteria\ClientOrderResourceCriteria::class); } /** * Display a list of client_order. * * @return Response */ public function index(ClientOrderRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Urdtlv\Clientpay\Repositories\Presenter\ClientOrderPresenter::class) ->$function(); } $client_orders = $this->repository->paginate(); return $this->response->title(trans('clientpay::client_order.names')) ->view('clientpay::client_order.index', true) ->data(compact('client_orders')) ->output(); } /** * Display client_order. * * @param Request $request * @param Model $client_order * * @return Response */ public function show(ClientOrderRequest $request, ClientOrder $client_order) { if ($client_order->exists) { $view = 'clientpay::client_order.show'; } else { $view = 'clientpay::client_order.new'; } return $this->response->title(trans('app.view') . ' ' . trans('clientpay::client_order.name')) ->data(compact('client_order')) ->view($view, true) ->output(); } /** * Show the form for creating a new client_order. * * @param Request $request * * @return Response */ public function create(ClientOrderRequest $request) { $client_order = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('clientpay::client_order.name')) ->view('clientpay::client_order.create', true) ->data(compact('client_order')) ->output(); } /** * Create new client_order. * * @param Request $request * * @return Response */ public function store(ClientOrderRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $client_order = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('clientpay::client_order.name')])) ->code(204) ->status('success') ->url(guard_url('clientpay/client_order/' . $client_order->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/clientpay/client_order')) ->redirect(); } } /** * Show client_order for editing. * * @param Request $request * @param Model $client_order * * @return Response */ public function edit(ClientOrderRequest $request, ClientOrder $client_order) { return $this->response->title(trans('app.edit') . ' ' . trans('clientpay::client_order.name')) ->view('clientpay::client_order.edit', true) ->data(compact('client_order')) ->output(); } /** * Update the client_order. * * @param Request $request * @param Model $client_order * * @return Response */ public function update(ClientOrderRequest $request, ClientOrder $client_order) { try { $attributes = $request->all(); $client_order->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('clientpay::client_order.name')])) ->code(204) ->status('success') ->url(guard_url('clientpay/client_order/' . $client_order->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('clientpay/client_order/' . $client_order->getRouteKey())) ->redirect(); } } /** * Remove the client_order. * * @param Model $client_order * * @return Response */ public function destroy(ClientOrderRequest $request, ClientOrder $client_order) { try { $client_order->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('clientpay::client_order.name')])) ->code(202) ->status('success') ->url(guard_url('clientpay/client_order/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('clientpay/client_order/' . $client_order->getRouteKey())) ->redirect(); } } /** * Remove multiple client_order. * * @param Model $client_order * * @return Response */ public function delete(ClientOrderRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('clientpay::client_order.name')])) ->status("success") ->code(202) ->url(guard_url('clientpay/client_order')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/clientpay/client_order')) ->redirect(); } } /** * Restore deleted client_orders. * * @param Model $client_order * * @return Response */ public function restore(ClientOrderRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('clientpay::client_order.name')])) ->status("success") ->code(202) ->url(guard_url('/clientpay/client_order')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/clientpay/client_order/')) ->redirect(); } } }