Example #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //
     $limit = Category::count() - 1;
     $categories = Category::skip(1)->take($limit)->get();
     return view('catalogs.categories.create')->with('categories', $categories);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CategoryRequest $request)
 {
     $category = new Category();
     // if ($request->hasFile('image'))
     // {
     //     $image = $request->file('image')->getClientOriginalName();
     //     $request->file('image')->move('img/categories/', $image);
     // }
     // else
     // {
     //     $image = 'no-image';
     // }
     $count = $category->count();
     if ($request->sort_id > 0) {
         $category->sort_id = $request->sort_id;
     } else {
         $category->sort_id = ++$count;
     }
     $category->section_id = $request->section_id;
     $category->title = $request->title;
     $category->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $category->image = $request->image;
     $category->title_description = $request->title_description;
     $category->meta_description = $request->meta_description;
     $category->text = $request->text;
     if ($request->status == 'on') {
         $category->status = 1;
     } else {
         $category->status = 0;
     }
     $category->save();
     return redirect('/admin/categories')->with('status', 'Категория добавлена!');
 }
 public function index()
 {
     $article_count = Article::count();
     $category_count = Category::count();
     $tag_count = Tag::count();
     $user_count = User::count();
     return view('admin.console', compact('article_count', 'category_count', 'tag_count', 'user_count'));
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     //App::setLocale('kh');
     //return trans('administrators.dashboard');
     //$user = Auth::user();
     //return $user->toJson();
     return View('admin.dashboard')->with(['user_total' => \App\User::count(), 'content_total' => \App\Content::count(), 'category_total' => \App\Category::count(), 'slider_total' => \App\Slider::count()]);
 }
 private function composeDashboard()
 {
     view()->composer('admin.index', function ($view) {
         $numArticle = \App\Article::count();
         $numCategory = \App\Category::count();
         $numTag = \App\Tag::count();
         $numProject = \App\Project::count();
         $numMessage = \App\Message::count();
         $view->with(compact('numArticle', 'numCategory', 'numTag', 'numProject', 'numMessage'));
     });
 }
 public function getCreate()
 {
     if (\Entrust::hasRole('Admin')) {
         if (Category::count()) {
             return view('a.productscreate')->with('cato', Category::lists('name', 'id'))->with('products', Product::all());
         } else {
             return redirect('admin/categories/view');
         }
     }
     return redirect('admin')->with('flash_message', 'You dont have permission to access create product page');
 }
Example #7
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts_published = Post::published()->count();
     $posts_editing = Post::where('published', 'uc')->count();
     $posts_sticky = Post::where('is_sticky', 'on')->count();
     $posts = Post::count();
     $users = User::count();
     $jobs = Job::count();
     $questions = Question::count();
     $categories = Category::count();
     return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
 }
Example #8
0
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('category', function (Builder $builder) {
         $builder->where('is_topic', 0)->where('is_ads', 0);
     });
     Category::creating(function ($category) {
         if (!$category->order) {
             $category->order = Category::count() + 1;
         }
     });
 }