/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data = [];
     $data['menu'] = Menu::findOrFail($id);
     $data['menus'] = Menu::findAllWithParent();
     $data['contents'] = Content::select('id', 'title')->where('state', 1)->lists('title', 'id')->prepend('Select a content', '')->toArray();
     $data['categories'] = Cat::select('id', 'name')->lists('name', 'id')->prepend('Select a category', '')->toArray();
     return view('admin.menu.form', $data);
 }
 /**
  * Compose left navigation for admin left menu
  */
 private function composeLeftNavigation()
 {
     view()->composer('admin.shared.left', function ($view) {
         $total = new \stdClass();
         $total->menu = Menu::count();
         $total->category = Cat::count();
         $total->content = Content::count();
         $view->with('total', $total);
     });
 }
Example #3
0
 public function pages()
 {
     $slug = Route::getCurrentRoute()->getPath();
     $content = Menu::where('slug', $slug)->first();
     if ($content->content_id > 0) {
         $content['data'] = $content->content;
         $content['data']['html'] = json_decode($content->content->content);
     } elseif ($content->cat_id > 0) {
         $cat_id = $content->category->id;
         $contents = Content::where('cat_id', $cat_id)->get();
         $array = [];
         $counter = 0;
         foreach ($contents as $c) {
             $array[$counter] = $c;
             $array[$counter]['html'] = json_decode($c->content);
             $counter++;
         }
         $content['data'] = collect($array)->toArray();
     }
     return $content;
 }
 /**
  * Unpublish items
  *
  * @param  UpdateStateRequest $request
  * @return \Illuminate\Http\Response
  */
 public function unpublish(UpdateStateRequest $request)
 {
     $items = $request->input('items');
     $request->session()->flash('alert-success', 'Selected categories has been unpublished!');
     return Content::whereIn('id', $items)->update(['state' => 0]);
 }