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