diff --git a/app/Http/Controllers/Admin/CompanyController.php b/app/Http/Controllers/Admin/CompanyController.php index 5632f5b..4a0671c 100644 --- a/app/Http/Controllers/Admin/CompanyController.php +++ b/app/Http/Controllers/Admin/CompanyController.php @@ -5,6 +5,8 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Company; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Validator; class CompanyController extends Controller { @@ -47,7 +49,7 @@ class CompanyController extends Controller */ public function show(Company $company) { - // + return view('admin.company.show', compact('company')); } /** @@ -58,7 +60,7 @@ class CompanyController extends Controller */ public function edit(Company $company) { - // + return view('admin.company.edit', compact('company')); } /** @@ -70,7 +72,27 @@ class CompanyController extends Controller */ public function update(Request $request, Company $company) { - // + $rules = [ + 'title' => 'required|min:3|max:255', + 'area_demo' => 'min:0|numeric', + 'workers' => 'min:0|numeric', + 'stock_area' => 'min:0|numeric', + 'name_equipment' => 'min:0|numeric', + ]; + + $messages = [ + 'required' => 'Поле не может быть пустым!', + ]; + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.company.show', ['company' => $company->id]) + ->withErrors($validator); + } else { + $params = $request->all(); + $company->update($params); + return redirect()->route('admin.company.show', ['company' => $company->id]); + } } /** diff --git a/app/Http/Controllers/Admin/NewsController.php b/app/Http/Controllers/Admin/NewsController.php index 1f5f847..c2bb247 100644 --- a/app/Http/Controllers/Admin/NewsController.php +++ b/app/Http/Controllers/Admin/NewsController.php @@ -58,6 +58,9 @@ class NewsController extends Controller $news->title = $request->title; $news->text = $request->text; $news->image = $request->file('image')->store('news', 'public'); + $news->author = $request->author; + $news->company = $request->company; + $news->status = $request->status; $news->save(); //$area->fotos()->save($foto_area); diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 0af6854..28f9e8c 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -12,19 +12,32 @@ use Symfony\Component\HttpFoundation\Session\Storage; class MainController extends Controller { // Главная страница - public function index() { + public function index(Request $request) { $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); + if (isset($request->filter)) { + switch($request->filter) { + case 'news':$goods = Good::query()->where('new', '=', '1')->orderBy('id')->paginate(8); + break; + case 'stock':$goods = Good::query()->where('stock_count', '>', '0')->orderBy('id')->paginate(8); + break; + case 'demo':$goods = Good::query()->where('demo', '=', '1')->orderBy('id')->paginate(8); + break; + case 'way':$goods = Good::query()->where('way', '=', '1')->orderBy('id')->paginate(8); + break; + } + } else { + $goods = Good::query()->where('new', '=', '1')->orderBy('id')->paginate(8); + } + + if ($request->ajax()) { + return view('index_catalog', compact('goods')); + } - $news = News::query()->orderByDesc('id')->paginate(3); + $news = News::query()->where('status', '=', 'новость')->orderByDesc('id')->paginate(3); return view('index', - compact('banners', 'category', 'goods_new', 'goods_stock', - 'goods_demo', 'goods_way', 'news')); + compact('banners', 'category', 'goods', 'news')); } public function about_company() { @@ -34,6 +47,8 @@ class MainController extends Controller public function catalog(Request $request) { $items = Category::all(); $goods = Good::query(); + $articles = News::query()->where('status', '=', 'статья')->paginate(10); + $reviews = News::query()->where('status', '=', 'отзыв')->paginate(3); if (!empty($request->filter)) { $filter = json_decode($request->filter); @@ -56,21 +71,38 @@ class MainController extends Controller return view('catalog_ajax', compact('goods')); } - - $mf = Good::select('manufacturer')->distinct()->pluck('manufacturer'); - return view('catalog', compact('items', 'goods', 'mf')); + return view('catalog', compact('items', 'goods', 'mf', 'articles', 'reviews')); } - public function catalog_detail(Category $category) { + public function catalog_detail(Category $category, Request $request) { $items = Category::all(); $title = $category->name; - $goods = Good::query()->where('category_id', '=', $category->id) - ->orderByDesc('id')->paginate(6); - $mf = Good::select('manufacturer')->distinct()->where('category_id', '=', $category->id) - ->pluck('manufacturer'); + $goods = Good::query()->where('category_id', '=', $category->id); + + if (!empty($request->filter)) { + $filter = json_decode($request->filter); + if (is_array($filter)) + if (count($filter) > 0) + $goods = $goods->whereIn('manufacturer', $filter); + } + + if ($request->sort == 'count') { + $goods = $goods->orderByDesc('stock_count')->orderByDesc('id'); + } + + if ($request->sort == 'price') { + $goods = $goods->orderBy('price')->orderByDesc('id'); + } + + $goods = $goods->paginate(6); + + if ($request->ajax()) { + return view('catalog_ajax', compact('goods')); + } - return view('catalog_detail', compact('items', 'goods', 'title', 'mf')); + $mf = Good::select('manufacturer')->distinct()->where('category_id', '=', $category->id)->pluck('manufacturer'); + return view('catalog_detail', compact('items', 'category', 'goods', 'title', 'mf')); } public function good(Good $good) { diff --git a/app/Models/Company.php b/app/Models/Company.php index cffe058..1e81c4e 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model; class Company extends Model { use HasFactory; + + protected $fillable = ['title', 'text', 'area_demo', 'workers', 'stock_area', 'name_equipment']; } diff --git a/app/Models/News.php b/app/Models/News.php index c300081..4a4f468 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -9,5 +9,5 @@ class News extends Model { use HasFactory; - protected $fillable = ['title', 'image', 'text']; + protected $fillable = ['title', 'image', 'text', 'author', 'company', 'status']; } diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index 1e47b04..2fec28d 100644 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Models\Category; +use App\Models\Company; use App\Models\Good; use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; @@ -44,6 +45,16 @@ class ComposerServiceProvider extends ServiceProvider $view->with(['items' => $items]); }); + $views = [ + 'layout.admin', + 'index', + 'company', + ]; + View::composer($views, + function($view) { + $company = Company::query()->where('id', '=', '1')->get(); + $view->with(['company' => $company]); + }); } diff --git a/resources/views/admin/company/edit.blade.php b/resources/views/admin/company/edit.blade.php new file mode 100644 index 0000000..bf17bc5 --- /dev/null +++ b/resources/views/admin/company/edit.blade.php @@ -0,0 +1,71 @@ +@extends('layout.admin', ['title' => 'Редактирование компании']) + +@section('content') +
+
+ + +
+
+@endsection diff --git a/resources/views/admin/company/show.blade.php b/resources/views/admin/company/show.blade.php new file mode 100644 index 0000000..56661b1 --- /dev/null +++ b/resources/views/admin/company/show.blade.php @@ -0,0 +1,41 @@ +@extends('layout.admin', ['title' => 'Просмотр компании']) + +@section('content') +
+
+

+ +

+ +
+

{{ $company->title }}



+ +
+

{{ $company->text }}



+ +
+

{{ $company->area_demo }}



+ +
+

{{ $company->workers }}



+ +
+

{{ $company->stock_area }}



+ +
+

{{ $company->name_equipment }}



+ + +
+
+@endsection diff --git a/resources/views/admin/news/form.blade.php b/resources/views/admin/news/form.blade.php index 8b90e2b..875e852 100644 --- a/resources/views/admin/news/form.blade.php +++ b/resources/views/admin/news/form.blade.php @@ -32,6 +32,51 @@ @endisset +
+@error('status') +
{{ $message }}
+@enderror +

+ +
+@error('author') +
{{ $message }}
+@enderror +

+ +
+@error('company') +
{{ $message }}
+@enderror +

+ + < diff --git a/resources/views/admin/news/index.blade.php b/resources/views/admin/news/index.blade.php index 73b6ff9..0e11051 100644 --- a/resources/views/admin/news/index.blade.php +++ b/resources/views/admin/news/index.blade.php @@ -7,7 +7,7 @@ Новости


@@ -16,6 +16,7 @@ + @@ -31,6 +32,7 @@ + + @endif diff --git a/resources/views/catalog.blade.php b/resources/views/catalog.blade.php index 7f3d610..2fff055 100644 --- a/resources/views/catalog.blade.php +++ b/resources/views/catalog.blade.php @@ -44,7 +44,7 @@ Ajax_query(); }); - $(document).on('click', '.highload2', function() { + $(document).on('change', '.check-highload', function() { console.log('Клик фильтр'); Ajax_query(); }); @@ -199,8 +199,8 @@
  • По наличию
  • По возрастанию цены
  • -
    -
    +
    +
    count()) {?> @foreach ($goods as $good)
    @@ -274,1490 +274,30 @@
    @endforeach -
    - - -
    - +
    + @if ($articles->count())

    Статьи по разделу

    + @foreach($articles as $article)
    - -

    Магнитный сверлильный станок - Вектор МС 36 или Rotabroach - Commando 40?

    + +

    {{$article->title}}

    -
    + @endforeach +
    @@ -1790,6 +330,7 @@ Показать все
    + @endif
    diff --git a/resources/views/catalog_ajax.blade.php b/resources/views/catalog_ajax.blade.php index 053dfae..7114ff1 100644 --- a/resources/views/catalog_ajax.blade.php +++ b/resources/views/catalog_ajax.blade.php @@ -1,3 +1,4 @@ +
    count()) {?> @foreach ($goods as $good)
    @@ -71,3 +72,8 @@
    @endforeach +
    + diff --git a/resources/views/catalog_detail.blade.php b/resources/views/catalog_detail.blade.php index d91c6c5..a3bcf87 100644 --- a/resources/views/catalog_detail.blade.php +++ b/resources/views/catalog_detail.blade.php @@ -1,5 +1,57 @@ @extends('layout.site', ['title' => $title]) +@section('script_js') + +@endsection + @section('content')
    @@ -141,10 +193,10 @@
      -
    • По наличию
    • -
    • По возрастанию цены
    • +
    • По наличию
    • +
    • По возрастанию цены
    -
    +
    count()) {?> @foreach ($goods as $good) @@ -219,1475 +271,13 @@
    @endforeach -
    - - -
    -
    diff --git a/resources/views/company.blade.php b/resources/views/company.blade.php index 0ae0166..14bb887 100644 --- a/resources/views/company.blade.php +++ b/resources/views/company.blade.php @@ -5,12 +5,12 @@
    @@ -18,11 +18,13 @@

    - Официальный дилер оборудования 50 мировых брендов для бизнеса - и частных предприятий + + {{$company[0]->title}}

    -

    +

    {{$company[0]->text}}

    +
    @@ -94,7 +96,7 @@

    - 600 кв.м + {{ $company[0]->area_demo }} кв.м

    демонстрационный зал @@ -102,7 +104,7 @@

    - 140 + {{ $company[0]->workers }}

    сотрудников @@ -110,7 +112,7 @@

    - 3 500 кв.м + {{ $company[0]->stock_area }} кв.м

    складских помещений @@ -118,7 +120,7 @@

    - 50 000 + {{ $company[0]->name_equipment }}

    наименований оборудования diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 8e7fbb3..0808d19 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -1,5 +1,44 @@ @extends('layout.site', ['title' => 'Векпром - главная страница']) +@section('script_js') + +@endsection + @section('banner') @include('banners.index') @endsection @@ -20,7 +59,7 @@

    @foreach ($category as $cat)
    - +

    {{$cat->name}}

    @@ -125,17 +164,17 @@ Каталог
      -
    • Новинки
    • -
    • В наличии на складе
    • -
    • В демозале
    • -
    • В пути
    • +
    • Новинки
    • +
    • В наличии на складе
    • +
    • В демозале
    • +
    • В пути
    -
    +
    - @if ($goods_new->count()) - @foreach ($goods_new as $good_new) + @if ($goods->count()) + @foreach ($goods as $good_new)
    @@ -207,1919 +246,66 @@
    @endforeach @endif - - - - - - - - - - - - - - -
    - -
    - -
    - - @if ($goods_demo->count()) - @foreach ($goods_demo as $good) -
    -
    -
    -
    - - - -

    Под заказ

    -
    -
    - - -
    -
    - -
    - @if (!empty($good->image)) -
    - @endif - -
    -
    -
    -
    - -

    - {{$good->text}} -

    -
    -
    - {{ $good->title }} -
    - -
    - @if ($good->price_old > 0) - {{$good->price_old}} ₽ - @endif - @if ($good->price > 0) -

    - {{$good->price}} ₽ -

    - @endif - -
    -
    -
    - @endforeach - @endif - - - - - - - - - - - -
    - -
    - - count()) {?> - @foreach ($goods_way as $good) -
    -
    -
    -
    - - - -

    Под заказ

    -
    -
    - - -
    -
    - -
    - @if (!empty($good->image)) -
    - @endif - -
    -
    -
    -
    - -

    - {{$good->text}} -

    -
    -
    - {{ $good->title }} -
    - -
    - @if ($good->price_old > 0) - {{$good->price_old}} ₽ - @endif - @if ($good->price > 0) -

    - {{$good->price}} ₽ -

    - @endif - -
    -
    -
    - @endforeach - - - - - - - - - - - - - -
    -
    - Смотреть все - -
    - - -
    -
    -

    Оборудование для цеха - обработки листа

    -
    -
    -
    - -
    -

    Станки

    -

    124 товара

    -
    -
    -
    - -
    -

    Оборудование

    -

    124 товара

    -
    -
    -
    - -
    -

    Машины

    -

    124 товара

    -
    -
    -
    - -
    -

    Упарвление

    -

    124 товара

    -
    -
    -
    - -
    -

    Приборы

    -

    124 товара

    -
    -
    -
    - -
    -

    Оборудование

    -

    124 товара

    +
    +
    + +
    +

    Оборудование

    +

    124 товара

    - +-->

    Автоматизация сварки

    @@ -2153,16 +339,18 @@

    О компании

    - Подробнее + Подробнее

    - Официальный дилер оборудования 50 мировых брендов для - бизнеса и частных предприятий. + {{ $company[0]->title }} +

    - С 2008 года подбираем оборудование под производственные + {{ $company[0]->text }} +

    -

    3500

    +

    {{ $company[0]->stock_area }}

    кв.м складских помещений

    -

    50 000

    +

    {{ $company[0]->name_equipment }}

    наименований в наличии

    -

    600

    +

    {{ $company[0]->area_demo }}

    кв.м демонстрационный зал оборудования

    -

    140

    +

    {{ $company[0]->workers }}

    сотрудников и специалистов

    @@ -2215,7 +403,7 @@

    {{ $new->title }}

    Читать далее - {{ date($new->created_at) }} + {{ date('d.m.Y', strtotime($new->created_at)) }}
    @endforeach diff --git a/resources/views/index_catalog.blade.php b/resources/views/index_catalog.blade.php new file mode 100644 index 0000000..d02a844 --- /dev/null +++ b/resources/views/index_catalog.blade.php @@ -0,0 +1,73 @@ +@if ($goods->count()) + @foreach ($goods as $good_new) +
    +
    +
    +
    + + + +

    Под заказ

    +
    +
    + + +
    +
    + +
    + @if (!empty($good_new->image)) +
    + @endif + +
    +
    +
    +
    + +

    + {{$good_new->text}} +

    +
    +
    + {{ $good_new->title }} +
    + +
    + @if ($good_new->price_old > 0) + {{$good_new->price_old}} ₽ + @endif + @if ($good_new->price > 0) +

    + {{$good_new->price}} ₽ +

    + @endif + +
    +
    +
    + @endforeach +@endif diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 4319eaa..1b57621 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -46,7 +46,11 @@
    @@ -721,14 +725,14 @@ Проекты


    -
    +
    @yield('content') diff --git a/resources/views/layout/site.blade.php b/resources/views/layout/site.blade.php index 38eae6e..5d18545 100644 --- a/resources/views/layout/site.blade.php +++ b/resources/views/layout/site.blade.php @@ -37,7 +37,7 @@
    -
    ID Фото ЗаголовокСтатус Дата создания Действия
    {{ $new->title }}{{ $new->status }} {{ $new->created_at }}
    @@ -50,6 +52,7 @@
    - - --