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