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