diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 28f9e8c..6683262 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Models\Banner; use App\Models\Category; use App\Models\Good; +use App\Models\Good_Look; use App\Models\News; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Session\Storage; @@ -48,7 +49,10 @@ class MainController extends Controller $items = Category::all(); $goods = Good::query(); $articles = News::query()->where('status', '=', 'статья')->paginate(10); - $reviews = News::query()->where('status', '=', 'отзыв')->paginate(3); + $reviews = News::query()->where('status', '=', 'отзыв')->paginate(10); + $lookin = Good_Look::query()->orderByDesc('id')->limit(4)->pluck('goods_id') + ->toArray(); + $lookin_good = Good::query()->whereIn('id', $lookin)->get(); if (!empty($request->filter)) { $filter = json_decode($request->filter); @@ -72,13 +76,19 @@ class MainController extends Controller } $mf = Good::select('manufacturer')->distinct()->pluck('manufacturer'); - return view('catalog', compact('items', 'goods', 'mf', 'articles', 'reviews')); + return view('catalog', compact('items', 'goods', + 'mf', 'articles', 'reviews', 'lookin_good')); } public function catalog_detail(Category $category, Request $request) { $items = Category::all(); $title = $category->name; $goods = Good::query()->where('category_id', '=', $category->id); + $articles = News::query()->where('status', '=', 'статья')->paginate(10); + $reviews = News::query()->where('status', '=', 'отзыв')->paginate(10); + $lookin = Good_Look::query()->orderByDesc('id')->limit(4)->pluck('goods_id') + ->toArray(); + $lookin_good = Good::query()->whereIn('id', $lookin)->get(); if (!empty($request->filter)) { $filter = json_decode($request->filter); @@ -102,11 +112,16 @@ class MainController extends Controller } $mf = Good::select('manufacturer')->distinct()->where('category_id', '=', $category->id)->pluck('manufacturer'); - return view('catalog_detail', compact('items', 'category', 'goods', 'title', 'mf')); + return view('catalog_detail', compact('items', 'category', 'goods', + 'title', 'mf', 'articles', 'reviews', 'lookin_good')); } public function good(Good $good) { - return view('good'); + $looking = new Good_Look(); + $looking->goods_id = $good->id; + $looking->save(); + + return view('good', compact('good')); } public function simple_good() { diff --git a/app/Models/Good_Look.php b/app/Models/Good_Look.php new file mode 100644 index 0000000..2a3b0c7 --- /dev/null +++ b/app/Models/Good_Look.php @@ -0,0 +1,11 @@ +id(); + $table->integer('goods_id')->nullable(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('good__looks'); + } +}; diff --git a/resources/views/catalog.blade.php b/resources/views/catalog.blade.php index 2fff055..bf447e0 100644 --- a/resources/views/catalog.blade.php +++ b/resources/views/catalog.blade.php @@ -409,17 +409,21 @@ + @if ($reviews->count()) Отзывы партнеров + @foreach($reviews as $review) - - Компания “Двери Олимп” - Соколов Алексей - Магнитный сверлильный станок Вектор МС 36 или Rotabroach Commando 40? + + {{$review->company}} + {{$review->author}} + {{$review->title}} + @endforeach + - + - + Показать все + @endif + @if ($lookin_good->count()) @@ -461,34 +467,35 @@ + @foreach ($lookin_good as $look) - - + src="./img/product/viewed/v-1-min.png" alt="">--> - Установка лазерной - резки GWEIKE + {{ $look->title }} - 250 990 ₽ + {{ $look->price }} ₽ В каталог - + @endforeach + @@ -611,4 +618,6 @@ + @endif + @endsection diff --git a/resources/views/catalog_detail.blade.php b/resources/views/catalog_detail.blade.php index a3bcf87..c1ea4d1 100644 --- a/resources/views/catalog_detail.blade.php +++ b/resources/views/catalog_detail.blade.php @@ -281,18 +281,19 @@ + @if ($articles->count()) Статьи по разделу + @foreach($articles as $article) - - Магнитный сверлильный станок - Вектор МС 36 или Rotabroach - Commando 40? + + {{$article->title}} - + @endforeach + - + - + Показать все + @endif @@ -402,19 +404,21 @@ - + @if ($reviews->count()) Отзывы партнеров + @foreach($reviews as $review) - - Компания “Двери Олимп” - Соколов Алексей - Магнитный сверлильный станок Вектор МС 36 или Rotabroach Commando 40? + + {{$review->company}} + {{$review->author}} + {{$review->title}} - + @endforeach + - + - + Показать все + @endif + @if ($lookin_good->count()) @@ -455,34 +461,36 @@ + @foreach ($lookin_good as $look) - + - + src="./img/product/viewed/v-1-min.png" alt="">--> + - Установка лазерной - резки GWEIKE + {{ $look->title }} - 250 990 ₽ + {{ $look->price }} ₽ В каталог - + @endforeach + @@ -605,4 +613,5 @@ + @endif @endsection diff --git a/resources/views/good.blade.php b/resources/views/good.blade.php index d75a660..00b6a96 100644 --- a/resources/views/good.blade.php +++ b/resources/views/good.blade.php @@ -425,10 +425,10 @@ - Главная / - Каталог / - Обработка металла / - Установка лазерной резки GWEIKE, серия LF 6025GH + Главная / + Каталог / + {{ $good->category->name }} / + {{ $good->title }}
Соколов Алексей
Магнитный сверлильный станок Вектор МС 36 или Rotabroach Commando 40?
{{$review->author}}
{{$review->title}}
250 990 ₽
{{ $look->price }} ₽