MainController.php 1.42 KB
<?php

namespace App\Http\Controllers;

use App\Models\Banner;
use App\Models\Category;
use App\Models\Good;
use App\Models\News;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Session\Storage;

class MainController extends Controller
{
    // Главная страница
    public function index() {
        $banners = Banner::query()->orderBy('id')->get();
        $category = Category::query()->where('parent_id', '>', '0')->orderBy('id')->get();

        $goods_new = Good::query()->where('new', '=', '1')->orderBy('id')->paginate(8);
        $goods_stock = Good::query()->where('stock_count', '>', '0')->orderBy('id')->paginate(8);
        $goods_demo = Good::query()->where('demo', '=', '1')->orderBy('id')->paginate(8);
        $goods_way = Good::query()->where('way', '=', '1')->orderBy('id')->paginate(8);

        $news = News::query()->orderByDesc('id')->paginate(3);
        return view('index',
            compact('banners', 'category', 'goods_new', 'goods_stock',
                             'goods_demo', 'goods_way', 'news'));
    }

    public function about_company() {
        return view('company');
    }

    public function catalog() {
        $category = Category::query()->orderBy('id')->get();
        return view('catalog', compact('category'));
    }

    public function good() {
        return view('good');
    }

    public function simple_good() {
        return view('simple_good');
    }
}