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