Commit 1bd0c6ebe84821ae10f026e65b05db4495cdad3b

Authored by Андрей Ларионов
1 parent 6eff6bf11b
Exists in master

Админка, товары. Фрондэнд главная страница

Showing 21 changed files with 491 additions and 24 deletions Side-by-side Diff

app/Http/Controllers/Admin/GoodController.php
... ... @@ -3,8 +3,10 @@
3 3 namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
  6 +use App\Http\Requests\GoodsRequest;
6 7 use App\Models\Good;
7 8 use Illuminate\Http\Request;
  9 +use Illuminate\Support\Facades\Storage;
8 10  
9 11 class GoodController extends Controller
10 12 {
... ... @@ -15,7 +17,9 @@ class GoodController extends Controller
15 17 */
16 18 public function index()
17 19 {
18   - //
  20 + $goods = Good::query()->orderBy('id')->paginate(5);
  21 + return view('admin.goods.index', compact('goods'));
  22 +
19 23 }
20 24  
21 25 /**
... ... @@ -25,7 +29,7 @@ class GoodController extends Controller
25 29 */
26 30 public function create()
27 31 {
28   - //
  32 + return view('admin.goods.create');
29 33 }
30 34  
31 35 /**
... ... @@ -34,9 +38,16 @@ class GoodController extends Controller
34 38 * @param \Illuminate\Http\Request $request
35 39 * @return \Illuminate\Http\Response
36 40 */
37   - public function store(Request $request)
  41 + public function store(GoodsRequest $request)
38 42 {
39   - //
  43 + $params = $request->all();
  44 +
  45 + if ($request->has('image')) {
  46 + $params['image'] = $request->file('image')->store('goods', 'public');
  47 + }
  48 +
  49 + Good::create($params);
  50 + return redirect()->route('admin.goods.index');
40 51 }
41 52  
42 53 /**
... ... @@ -58,7 +69,7 @@ class GoodController extends Controller
58 69 */
59 70 public function edit(Good $good)
60 71 {
61   - //
  72 + return view('admin.goods.edit', compact('good'));
62 73 }
63 74  
64 75 /**
... ... @@ -70,7 +81,17 @@ class GoodController extends Controller
70 81 */
71 82 public function update(Request $request, Good $good)
72 83 {
73   - //
  84 + $params = $request->all();
  85 +
  86 + if ($request->has('image')) {
  87 + if (!empty($good->image)) Storage::delete($good->image);
  88 + $params['image'] = $request->file('image')->store('goods', 'public');
  89 + } else {
  90 + if (!empty($good->image)) $params['image'] = $good->image;
  91 + }
  92 +
  93 + $good->update($params);
  94 + return redirect()->route('admin.goods.index');
74 95 }
75 96  
76 97 /**
... ... @@ -81,6 +102,10 @@ class GoodController extends Controller
81 102 */
82 103 public function destroy(Good $good)
83 104 {
84   - //
  105 + if (!empty($good->image)) {
  106 + Storage::delete($good->image);
  107 + }
  108 + $good->delete();
  109 + return redirect()->route('admin.goods.index');
85 110 }
86 111 }
app/Http/Controllers/MainController.php
... ... @@ -2,12 +2,16 @@
2 2  
3 3 namespace App\Http\Controllers;
4 4  
  5 +use App\Models\Banner;
  6 +use App\Models\Category;
5 7 use Illuminate\Http\Request;
6 8  
7 9 class MainController extends Controller
8 10 {
9 11 public function index() {
10   - return view('index');
  12 + $banners = Banner::query()->orderBy('id')->get();
  13 + $category = Category::query()->where('parent_id', '>', '0')->orderBy('id')->get();
  14 + return view('index', compact('banners', 'category'));
11 15 }
12 16  
13 17 public function about_company() {
... ... @@ -15,7 +19,8 @@ class MainController extends Controller
15 19 }
16 20  
17 21 public function catalog() {
18   - return view('catalog');
  22 + $category = Category::query()->orderBy('id')->get();
  23 + return view('catalog', compact('category'));
19 24 }
20 25  
21 26 public function good() {
app/Http/Requests/GoodsRequest.php
... ... @@ -0,0 +1,39 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Requests;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class GoodsRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 +
  19 + /**
  20 + * Get the validation rules that apply to the request.
  21 + *
  22 + * @return array<string, mixed>
  23 + */
  24 + public function rules()
  25 + {
  26 + return [
  27 + 'title' => 'required|min:3|max:255',
  28 + 'price' => 'required|min:0|numeric',
  29 + 'price_old' => 'required|min:0|numeric',
  30 + 'manufacturer' => 'required|min:0|max:255',
  31 + 'country' => 'required|min:0|max:255',
  32 + 'power' => 'required|min:0|numeric',
  33 + 'image' => [
  34 + 'mimes:jpeg,jpg,png',
  35 + 'max:10000'
  36 + ],
  37 + ];
  38 + }
  39 +}
app/Models/Category.php
... ... @@ -10,4 +10,8 @@ class Category extends Model
10 10 use HasFactory;
11 11  
12 12 protected $fillable = ['name', 'image', 'content', 'parent_id'];
  13 +
  14 + public function goods() {
  15 + return $this->hasMany(Good::class);
  16 + }
13 17 }
... ... @@ -8,4 +8,15 @@ use Illuminate\Database\Eloquent\Model;
8 8 class Good extends Model
9 9 {
10 10 use HasFactory;
  11 +
  12 + protected $fillable = ['title', 'image', 'category_id', 'price',
  13 + 'price_old', 'manufacturer', 'country', 'size',
  14 + 'power', 'description', 'feature', 'equipment',
  15 + 'accessory_id', 'tooling_id', 'weight', 'new',
  16 + 'stock_count', 'demo', 'way', 'type_good'
  17 + ];
  18 +
  19 + public function category() {
  20 + return $this->belongsTo(Category::class, 'category_id');
  21 + }
11 22 }
... ... @@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
8 8 class News extends Model
9 9 {
10 10 use HasFactory;
  11 +
  12 + protected $fillable = ['title', 'image', 'text'];
11 13 }
app/Models/Project.php
... ... @@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
8 8 class Project extends Model
9 9 {
10 10 use HasFactory;
  11 +
  12 + protected $fillable = ['title', 'image', 'customer', 'date_project'];
11 13 }
app/Providers/ComposerServiceProvider.php
... ... @@ -3,6 +3,7 @@
3 3 namespace App\Providers;
4 4  
5 5 use App\Models\Category;
  6 +use App\Models\Good;
6 7 use Illuminate\Support\Facades\View;
7 8 use Illuminate\Support\ServiceProvider;
8 9  
... ... @@ -20,6 +21,7 @@ class ComposerServiceProvider extends ServiceProvider
20 21 'admin.part.categories', //выбор категории поста при редактировании
21 22 'admin.part.parents', //выбор родителя категории при редактировании
22 23 'admin.part.all-ctgs', //все категории в административной части
  24 + 'admin.part.category_id',
23 25 ];
24 26 View::composer($views,
25 27 function($view) {
... ... @@ -29,6 +31,20 @@ class ComposerServiceProvider extends ServiceProvider
29 31 }
30 32 $view->with(['items' => $items]);
31 33 });
  34 +
  35 + $views = [
  36 + 'admin.part.goods',
  37 + ];
  38 + View::composer($views,
  39 + function($view) {
  40 + static $items = null;
  41 + if (is_null($items)) {
  42 + $items = Good::all();
  43 + }
  44 + $view->with(['items' => $items]);
  45 + });
  46 +
  47 +
32 48 }
33 49  
34 50 /**
database/migrations/2023_03_31_121853_create_goods_table.php
... ... @@ -19,6 +19,7 @@ return new class extends Migration
19 19 $table->string('title', 255);
20 20 $table->integer('price')->default(0);
21 21 $table->integer('price_old')->default(0);
  22 + $table->string('image', 255)->nullable();
22 23 $table->string('manufacturer', 255)->nullable();
23 24 $table->string('country', 255)->nullable();
24 25 $table->string('size', 255)->nullable();
database/migrations/2023_03_31_122437_create_news_table.php
... ... @@ -18,6 +18,9 @@ return new class extends Migration
18 18 $table->string('title', 255)->nullable();
19 19 $table->text('text')->nullable();
20 20 $table->string('image', 255)->nullable();
  21 + $table->string('status', 50)->default('новость');
  22 + $table->string('author', 255)->nullable();
  23 + $table->string('company', 255)->nullable();
21 24 $table->timestamps();
22 25 });
23 26 }
resources/views/admin/goods/create.blade.php
... ... @@ -0,0 +1,15 @@
  1 +@extends('layout.admin', ['title' => 'Создание товара'])
  2 +
  3 +@section('content')
  4 + <div class="profile-block-wrapper">
  5 + <div class="profile-block">
  6 + <h2 class="modal-auth__title">
  7 + Создание товара
  8 + </h2>
  9 + <form method="post" enctype="multipart/form-data" class="modal-auth-form" action="{{ route('admin.goods.store') }}">
  10 + @include('admin.goods.form')
  11 + </form>
  12 +
  13 + </div>
  14 + </div>
  15 +@endsection
resources/views/admin/goods/edit.blade.php
... ... @@ -0,0 +1,14 @@
  1 +@extends('layout.admin', ['title' => 'Редактирование товара'])
  2 +
  3 +@section('content')
  4 + <div class="profile-block-wrapper">
  5 + <div class="profile-block">
  6 + <h2 class="modal-auth__title">
  7 + Редактирование товара
  8 + </h2>
  9 + <form method="post" enctype="multipart/form-data" class="modal-auth-form" action="{{ route('admin.goods.update', ['good' => $good->id]) }}">
  10 + @include('admin.goods.form')
  11 + </form>
  12 + </div>
  13 + </div>
  14 +@endsection
resources/views/admin/goods/form.blade.php
... ... @@ -0,0 +1,237 @@
  1 +@csrf
  2 +
  3 +@isset($good)
  4 + @method('PUT')
  5 +@endisset
  6 +
  7 +<label class="form__label" for="title">Заголовок товара
  8 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  9 +</label><br>
  10 +@error('title')
  11 +<div class="alert alert-danger">{{ $message }}</div>
  12 +@enderror
  13 +<input class="form-input " type="text" id="title" name="title" placeholder="Введите заголовок" required value="{{ old('title') ?? $good->title ?? '' }}"><br><br>
  14 +
  15 +<label class="form__label" for="category_id">Категория
  16 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  17 +</label><br>
  18 +
  19 +<div class="form-group">
  20 + @php
  21 + $parent_id = old('category_id') ?? $good->category_id ?? 0;
  22 + @endphp
  23 + <select name="category_id" class="form-control" title="Категория">
  24 + <option value="0">Без родителя</option>
  25 + @include('admin.part.category_id', ['level' => -1, 'parent' => 0])
  26 + </select>
  27 +</div>
  28 +
  29 +<label class="form__label" for="price">Цена
  30 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  31 +</label><br>
  32 +@error('price')
  33 +<div class="alert alert-danger">{{ $message }}</div>
  34 +@enderror
  35 +<input class="form-input " type="text" id="price" name="price" placeholder="Введите цену" required value="{{ old('price') ?? $good->price ?? '' }}"><br><br>
  36 +
  37 +<label class="form__label" for="price_old">Цена старая
  38 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  39 +</label><br>
  40 +@error('price_old')
  41 +<div class="alert alert-danger">{{ $message }}</div>
  42 +@enderror
  43 +<input class="form-input " type="text" id="price_old" name="price_old" placeholder="Введите цену" value="{{ old('price_old') ?? $good->price_old ?? '' }}"><br><br>
  44 +
  45 +<label class="form__label" for="manufacturer">Производитель
  46 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  47 +</label><br>
  48 +@error('manufacturer')
  49 +<div class="alert alert-danger">{{ $message }}</div>
  50 +@enderror
  51 +<input class="form-input " type="text" id="manufacturer" name="manufacturer" placeholder="Введите производителя" required value="{{ old('manufacturer') ?? $good->manufacturer ?? '' }}"><br><br>
  52 +
  53 +<label class="form__label" for="country">Страна
  54 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  55 +</label><br>
  56 +@error('country')
  57 +<div class="alert alert-danger">{{ $message }}</div>
  58 +@enderror
  59 +<input class="form-input " type="text" id="country" name="country" placeholder="Введите страну" required value="{{ old('country') ?? $good->country ?? '' }}"><br><br>
  60 +
  61 +<label class="form__label" for="size">Размер-габарит
  62 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  63 +</label><br>
  64 +@error('size')
  65 +<div class="alert alert-danger">{{ $message }}</div>
  66 +@enderror
  67 +<input class="form-input " type="text" id="size" name="size" placeholder="Введите размер-габарит" value="{{ old('size') ?? $good->size ?? '' }}"><br><br>
  68 +
  69 +<label class="form__label" for="power">Мощность
  70 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  71 +</label><br>
  72 +@error('power')
  73 +<div class="alert alert-danger">{{ $message }}</div>
  74 +@enderror
  75 +<input class="form-input " type="text" id="power" name="power" placeholder="Введите мощность" value="{{ old('power') ?? $good->power ?? '' }}"><br><br>
  76 +
  77 +<label class="form__label" for="description">Описание товара
  78 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  79 +</label><br>
  80 +@error('description')
  81 +<div class="alert alert-danger">{{ $message }}</div>
  82 +@enderror
  83 +<textarea class="form-input " id="description" name="description" placeholder="Введите описание"
  84 + required>{{ old('description') ?? $good->description ?? '' }}</textarea><br><br>
  85 +
  86 +<label class="form__label" for="feature">Характеристики
  87 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  88 +</label><br>
  89 +@error('feature')
  90 +<div class="alert alert-danger">{{ $message }}</div>
  91 +@enderror
  92 +<textarea class="form-input " id="feature" name="feature" placeholder="Введите характеристики"
  93 + required>{{ old('feature') ?? $good->feature ?? '' }}</textarea><br><br>
  94 +
  95 +<label class="form__label" for="equipment">Комплектация
  96 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  97 +</label><br>
  98 +@error('equipment')
  99 +<div class="alert alert-danger">{{ $message }}</div>
  100 +@enderror
  101 +<textarea class="form-input " id="equipment" name="equipment" placeholder="Введите комплектацию"
  102 + required>{{ old('equipment') ?? $good->equipment ?? '' }}</textarea><br><br>
  103 +
  104 +<div class="form-group">
  105 + <label class="form__label" for="accessory_id">Аксессуары
  106 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  107 + </label><br>
  108 + @php
  109 + $current_id = old('accessory_id') ?? $good->accessory_id ?? 0;
  110 + @endphp
  111 + <select name="accessory_id" class="form-control" title="Аксессуары">
  112 + <option value="0">Без родителя</option>
  113 + @include('admin.part.goods')
  114 + </select>
  115 +</div>
  116 +
  117 +<div class="form-group">
  118 + <label class="form__label" for="tooling_id">Оснастка
  119 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  120 + </label><br>
  121 + @php
  122 + $current_id = old('tooling_id') ?? $good->tooling_id ?? 0;
  123 + @endphp
  124 + <select name="tooling_id" class="form-control" title="Оснастка">
  125 + <option value="0">Без родителя</option>
  126 + @include('admin.part.goods')
  127 + </select>
  128 +</div>
  129 +
  130 +<label class="form__label" for="weight">Вес
  131 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  132 +</label><br>
  133 +@error('weight')
  134 +<div class="alert alert-danger">{{ $message }}</div>
  135 +@enderror
  136 +<input class="form-input " type="text" id="weight" name="weight" placeholder="Введите вес" value="{{ old('weight') ?? $good->weight ?? '' }}"><br><br>
  137 +
  138 +<label class="form__label" for="stock_count">Количество на складе
  139 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  140 +</label><br>
  141 +@error('stock_count')
  142 +<div class="alert alert-danger">{{ $message }}</div>
  143 +@enderror
  144 +<input class="form-input " type="text" id="stock_count" name="stock_count" placeholder="Введите кол-во" value="{{ old('stock_count') ?? $good->stock_count ?? '' }}"><br><br>
  145 +
  146 +<label class="form__label" for="type_good">Тип товара
  147 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  148 +</label><br>
  149 +@error('type_good')
  150 +<div class="alert alert-danger">{{ $message }}</div>
  151 +@enderror
  152 +<input class="form-input " type="text" id="type_good" name="type_good" placeholder="Введите тип товара" value="{{ old('type_good') ?? $good->type_good ?? '' }}"><br><br>
  153 +
  154 +<label class="form__label" for="new">Новинка
  155 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  156 +</label><br>
  157 +@error('new')
  158 +<div class="alert alert-danger">{{ $message }}</div>
  159 +@enderror
  160 +<select name="new" id="new" class="form-control">
  161 + <option value="1"
  162 + @isset($good)
  163 + @if($good->new == '1')
  164 + selected
  165 + @endif
  166 + @endisset
  167 + >Есть</option>
  168 + <option value="0"
  169 + @isset($good)
  170 + @if($good->new == '0')
  171 + selected
  172 + @endif
  173 + @endisset
  174 + >Нет</option>
  175 +</select><br>
  176 +
  177 +<label class="form__label" for="demo">Демо-зал
  178 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  179 +</label><br>
  180 +@error('demo')
  181 +<div class="alert alert-danger">{{ $message }}</div>
  182 +@enderror
  183 +<select name="demo" id="demo" class="form-control">
  184 + <option value="1"
  185 + @isset($good)
  186 + @if($good->demo == '1')
  187 + selected
  188 + @endif
  189 + @endisset
  190 + >Есть</option>
  191 + <option value="0"
  192 + @isset($good)
  193 + @if($good->demo == '0')
  194 + selected
  195 + @endif
  196 + @endisset
  197 + >Нет</option>
  198 +</select><br>
  199 +
  200 +<label class="form__label" for="way">В пути
  201 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  202 +</label><br>
  203 +@error('way')
  204 +<div class="alert alert-danger">{{ $message }}</div>
  205 +@enderror
  206 +<select name="way" id="way" class="form-control">
  207 + <option value="1"
  208 + @isset($good)
  209 + @if($good->way == '1')
  210 + selected
  211 + @endif
  212 + @endisset
  213 + >Есть</option>
  214 + <option value="0"
  215 + @isset($good)
  216 + @if($good->way == '0')
  217 + selected
  218 + @endif
  219 + @endisset
  220 + >Нет</option>
  221 +</select><br>
  222 +
  223 +
  224 +<label class="form__label" for="image">Картинка
  225 + <span class="auth-mail-error auth-mail-error--hidden">Ошибка</span>
  226 +</label><br>
  227 +<input type="file" class="form-input form-control-file " name="image" id="image" accept="image/png, image/jpeg">
  228 +@isset($category->image)
  229 + <div class="form-group form-check">
  230 + <img src="<?=asset(Storage::url($category->image))?>" width="100px"/>
  231 + </div>
  232 +@endisset
  233 +
  234 +
  235 +<<div class="parts-content-form-bottom modal-auth-bottom">
  236 + <button class="parts-content-form-bottom__button" type="submit">Сохранить</button>
  237 +</div>
resources/views/admin/goods/index.blade.php
... ... @@ -0,0 +1,66 @@
  1 +@extends('layout.admin', ['title' => 'Товары'])
  2 +
  3 +@section('content')
  4 + <div class="profile-block-wrapper">
  5 + <div class="profile-block">
  6 + <h2 class="modal-auth__title_">
  7 + Товары
  8 + </h2><br>
  9 + <a href="{{ route('admin.goods.create') }}" class="btn banner-container__button" style="margin: 0px;">
  10 + Создать товар
  11 + </a><br><br>
  12 +
  13 + <table class="table" style="width: 100%">
  14 + <thead>
  15 + <tr>
  16 + <th>ID</th>
  17 + <th>Фото</th>
  18 + <th>Категория</th>
  19 + <th>Товар</th>
  20 + <th>Дата создания</th>
  21 + <th>Действия</th>
  22 + </tr>
  23 + </thead>
  24 + <tbody>
  25 + @if ($goods->count())
  26 + @foreach($goods as $good)
  27 + <tr>
  28 + <td>{{ $good->id }}</td>
  29 + <td><? if (empty($good->image)) {?>Нет фото<?} else {?>
  30 + <!--<img src="/storage/app/public/<?//=$area->foto_main; //=asset(Storage::url($area->foto_main))?>" width="100px"/>-->
  31 + <img src="<?=asset(Storage::url($good->image))?>" width="100px"/>
  32 + <?}?></td>
  33 + <td>{{ $good->category->name }}</td>
  34 + <td>{{ $good->title }}</td>
  35 + <td>{{ $good->created_at }}</td>
  36 + <td> <form action="{{ route('admin.goods.destroy', $good) }}" method="POST">
  37 + <a href="{{ route('admin.goods.edit', ['good' => $good->id]) }}">
  38 + Редактировать
  39 + </a> |
  40 + @csrf
  41 + @method('DELETE')
  42 + <input class=" btn-danger" type="submit" value="Удалить">
  43 + </form>
  44 + </td>
  45 + </tr>
  46 + @endforeach
  47 + @else
  48 + <tr>
  49 + <td>-</td>
  50 + <td>-</td>
  51 + <td>-</td>
  52 + <td>-</td>
  53 + <td>-</td>
  54 + <td>-</td>
  55 + </tr>
  56 + @endif
  57 +
  58 + </tbody>
  59 + </table>
  60 +
  61 + {{ $goods->onEachSide(1)->links('catalogs.paginate') }}
  62 +
  63 + </div>
  64 + </div>
  65 + <br><br>
  66 +@endsection
resources/views/admin/news/edit.blade.php
... ... @@ -6,7 +6,7 @@
6 6 <h2 class="modal-auth__title">
7 7 Редактирование новости
8 8 </h2>
9   - <form method="post" enctype="multipart/form-data" class="modal-auth-form" action="{{ route('admin.news.update', ['category' => $category->id]) }}">
  9 + <form method="post" enctype="multipart/form-data" class="modal-auth-form" action="{{ route('admin.news.update', ['news' => $news->id]) }}">
10 10 @include('admin.news.form')
11 11 </form>
12 12 </div>
resources/views/admin/part/category_id.blade.php
... ... @@ -0,0 +1,10 @@
  1 +@if ($items->where('parent_id', $parent)->count())
  2 + @php $level++ @endphp
  3 + @foreach ($items->where('parent_id', $parent) as $item)
  4 + <option value="{{ $item->id }}" @if ($item->id == $parent_id) selected @endif>
  5 + @if ($level) {!! str_repeat('&nbsp;&nbsp;&nbsp;', $level) !!} @endif
  6 + {{ $item->name }}
  7 + </option>
  8 + @include('admin.part.category_id', ['level' => $level, 'parent' => $item->id])
  9 + @endforeach
  10 +@endif
resources/views/admin/part/goods.blade.php
... ... @@ -0,0 +1,7 @@
  1 +@if ($items->count())
  2 + @foreach ($items as $item)
  3 + <option value="{{ $item->id }}" @if ($item->id == $current_id) selected @endif>
  4 + ({{ $item->id }}) {{ $item->title }}
  5 + </option>
  6 + @endforeach
  7 +@endif
resources/views/banners/index.blade.php
  1 +@if ($banners->count())
1 2 <section class="slider">
2 3 <div class="container">
3 4 <div class="sw-wr">
4 5 <div class="swiper mySwiper custom-swiper">
5 6 <div class="swiper-wrapper">
  7 + @foreach ($banners as $banner)
6 8 <div class="swiper-slide swiper-slide-custom">
7 9 <div class="slide-text">
8 10 <h2 class="slide-text__title">
9   - Поставляем промышленное оборудование с 2008 года
  11 + {{$banner->title}}
10 12 </h2>
11 13 <div class="slide-text__paragr">
12   - <p class="par-one">Горизонтальный фрезерный центр с ЧПУ</p>
13   - <p class="par-two">SINO HMC1000P</p>
  14 + <p class="par-one">{{$banner->text}}</p>
  15 + <!--<p class="par-two">SINO HMC1000P</p>-->
14 16 </div>
15 17 </div>
16   - <img class="slider-img" src="./img/main/slider/slider-1.png" alt="Изображение слайдера">
  18 + <img class="slider-img" src="{{ asset(Storage::url($banner->image)) }}" alt="{{$banner->title}}">
  19 + <!--<img class="slider-img" src="./img/main/slider/slider-1.png" alt="Изображение слайдера">-->
17 20 </div>
18   - <div class="swiper-slide swiper-slide-custom">
  21 + @endforeach
  22 + <!--<div class="swiper-slide swiper-slide-custom">
19 23 <div class="slide-text">
20 24 <h2 class="slide-text__title">
21 25 Поставляем промышленное оборудование с 2008 года
... ... @@ -38,16 +42,17 @@
38 42 </div>
39 43 </div>
40 44 <img class="slider-img" src="./img/main/slider/slider-1.png" alt="">
41   - </div>
  45 + </div>-->
42 46 </div>
43 47 <div class="swiper-button-next">
44   - <img class="slider-next" src="./img/main/slider/slider-next.svg" alt="">
  48 + <img class="slider-next" src="{{ asset('/img/main/slider/slider-next.svg') }}" alt="">
45 49 </div>
46 50 <div class="swiper-button-prev">
47   - <img class="slider-prev" src="./img/main/slider/slider-next.svg" alt="">
  51 + <img class="slider-prev" src="{{ asset('/img/main/slider/slider-next.svg') }}" alt="">
48 52 </div>
49 53 <div class="swiper-pagination custom-pagination"></div>
50 54 </div>
51 55 </div>
52 56 </div>
53 57 </section>
  58 +@endif
resources/views/index.blade.php
... ... @@ -14,22 +14,25 @@
14 14 </div>
15 15 </section>
16 16  
  17 + @if ($category->count())
17 18 <section class="bloks">
18 19 <div class="container">
19 20 <div class="bloks-wrapper">
  21 + @foreach ($category as $cat)
20 22 <div class="bloks-item">
21 23 <a href="#">
22 24 <div class="item-wrapper">
23 25 <div class="blocks__item-text">
24   - <h3 class="item-title">Станки для механической обработки металла с ЧПУ</h3>
  26 + <h3 class="item-title">{{$cat->name}}</h3>
25 27 <div class="svg-wrapper">
26 28 </div>
27 29 </div>
28   - <img class="bloks__item-img" src="./img/main/bloks/1.png" alt="">
  30 + <img class="bloks__item-img" width="150px" src="{{asset(Storage::url($cat->image))}}" alt="{{$cat->name}}">
29 31 </div>
30 32 </a>
31 33 </div>
32   - <div class="bloks-item">
  34 + @endforeach
  35 + <!--<div class="bloks-item">
33 36 <a href="#">
34 37 <div class="item-wrapper">
35 38 <div class="blocks__item-text">
... ... @@ -98,10 +101,11 @@
98 101 <img class="bloks__item-img img-six" src="./img/main/bloks/6.png" alt="">
99 102 </div>
100 103 </a>
101   - </div>
  104 + </div>-->
102 105 </div>
103 106 </div>
104 107 </section>
  108 + @endif
105 109  
106 110 <section class="banner">
107 111 <div class="container">
resources/views/layout/admin.blade.php
... ... @@ -461,7 +461,7 @@
461 461 <!--<span>(5)</span>-->
462 462 </li>
463 463 <li class="tab account-tabs__item" data-tab=".js-tab_5">
464   - <a href="{{ route('user.index') }}">Товары</a>
  464 + <a href="{{ route('admin.goods.index') }}">Товары</a>
465 465 </li>
466 466 <li class="tab account-tabs__item" data-tab=".js-tab_5">
467 467 <a href="{{ route('admin.project.index') }}">Проекты</a>
... ... @@ -2,6 +2,7 @@
2 2  
3 3 use App\Http\Controllers\Admin\BannerController;
4 4 use App\Http\Controllers\Admin\CategoryController;
  5 +use App\Http\Controllers\Admin\GoodController;
5 6 use App\Http\Controllers\Admin\NewsController;
6 7 use App\Http\Controllers\Admin\ProjectController;
7 8 use App\Http\Controllers\AdminController;
... ... @@ -105,7 +106,7 @@ Route::group([
105 106 /*
106 107 * CRUD-операции над категориями
107 108 */
108   - Route::resource('goods', CategoryController::class, ['except' => ['show']]);
  109 + Route::resource('goods', GoodController::class, ['except' => ['show']]);
109 110  
110 111 /*
111 112 * CRUD-операции над категориями