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