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