From c5f46e4d5f4508c3382d88d021f57a2361a51f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Wed, 12 Apr 2023 21:34:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=BC=D0=B0=D1=82=D1=80=D0=B8=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=D0=B5=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D1=8B=20=D0=B8?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D1=8B=20=D0=BD=D0=B0=20=D1?= =?UTF-8?q?=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MainController.php | 23 ++++++-- app/Models/Good_Look.php | 11 ++++ .../2023_04_12_094609_create_good__looks_table.php | 32 ++++++++++ resources/views/catalog.blade.php | 39 ++++++++----- resources/views/catalog_detail.blade.php | 61 +++++++++++--------- resources/views/good.blade.php | 8 +-- 6 files changed, 125 insertions(+), 49 deletions(-) create mode 100644 app/Models/Good_Look.php create mode 100644 database/migrations/2023_04_12_094609_create_good__looks_table.php 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 @@
-- 1.7.10.4