form = DemoRestaurantForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('litecms.demo.modules'), 'demo', guard_url('demo')); } /** * Display a list of demo_restaurant. * * @return Response */ public function index(DemoRestaurantResourceRequest $request) { $request = $request->all(); $page = DemoRestaurantActions::run('paginate', $request); $data = new DemoRestaurantsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('demo::demo_restaurant.names')) ->view('demo::demo_restaurant.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display demo_restaurant. * * @param Request $request * @param Model $demo_restaurant * * @return Response */ public function show(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { $form = $this->form; $modules = $this->modules; $data = new DemoRestaurantResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('demo::demo_restaurant.name')) ->data(compact('data', 'form', 'modules')) ->view('demo::demo_restaurant.show') ->output(); } /** * Show the form for creating a new demo_restaurant. * * @param Request $request * * @return Response */ public function create(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { $form = $this->form; $modules = $this->modules; $data = new DemoRestaurantResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('demo::demo_restaurant.name')) ->view('demo::demo_restaurant.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new demo_restaurant. * * @param Request $request * * @return Response */ public function store(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { try { $request = $request->all(); $model = DemoRestaurantAction::run('store', $model, $request); $data = new DemoRestaurantResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('demo::demo_restaurant.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('demo/demo_restaurant/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/demo/demo_restaurant')) ->redirect(); } } /** * Show demo_restaurant for editing. * * @param Request $request * @param Model $demo_restaurant * * @return Response */ public function edit(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { $form = $this->form; $modules = $this->modules; $data = new DemoRestaurantResource($model); // return view('demo::demo_restaurant.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('demo::demo_restaurant.name')) ->view('demo::demo_restaurant.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the demo_restaurant. * * @param Request $request * @param Model $demo_restaurant * * @return Response */ public function update(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { try { $request = $request->all(); $model = DemoRestaurantAction::run('update', $model, $request); $data = new DemoRestaurantResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('demo::demo_restaurant.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('demo/demo_restaurant/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('demo/demo_restaurant/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the demo_restaurant. * * @param Model $demo_restaurant * * @return Response */ public function destroy(DemoRestaurantResourceRequest $request, DemoRestaurant $model) { try { $request = $request->all(); $model = DemoRestaurantAction::run('destroy', $model, $request); $data = new DemoRestaurantResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('demo::demo_restaurant.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('demo/demo_restaurant/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('demo/demo_restaurant/' . $model->getRouteKey())) ->redirect(); } } }