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