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