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