diff --git a/app/Http/Controllers/Admin/BannerController.php b/app/Http/Controllers/Admin/BannerController.php
new file mode 100644
index 0000000..ac6a5b0
--- /dev/null
+++ b/app/Http/Controllers/Admin/BannerController.php
@@ -0,0 +1,138 @@
+orderBy('id')->paginate(5);
+ return view('admin.banners.index', compact('banners'));
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function create()
+ {
+ return view('admin.banners.create');
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function store(Request $request)
+ {
+ $rules = [
+ 'image' => 'required|min:3|max:10000',
+ 'title' => 'required|min:3|max:255'
+ ];
+ $messages = [
+ 'required' => 'Поле не может быть пустым!',
+ ];
+ $validator = Validator::make($request->all(), $rules, $messages);
+
+ if ($validator->fails()) {
+ return redirect()->route('admin.banner.create')
+ ->withErrors($validator);
+ } else {
+
+ $banner = new Banner();
+ $banner->title = $request->title;
+ $banner->text = $request->text;
+ $banner->image = $request->file('image')->store('banners', 'public');
+ $banner->save();
+
+ //$area->fotos()->save($foto_area);
+ return redirect()->route('admin.banner.index');
+ }
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @param \App\Models\Banner $banner
+ * @return \Illuminate\Http\Response
+ */
+ public function show(Banner $banner)
+ {
+ //
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param \App\Models\Banner $banner
+ * @return \Illuminate\Http\Response
+ */
+ public function edit(Banner $banner)
+ {
+ return view('admin.banners.edit', compact($banner));
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \App\Models\Banner $banner
+ * @return \Illuminate\Http\Response
+ */
+ public function update(Request $request, Banner $banner)
+ {
+ $rules = [
+ 'image' => 'required|min:3|max:10000',
+ 'title' => 'required|min:3|max:255'
+ ];
+ $messages = [
+ 'required' => 'Поле не может быть пустым!',
+ ];
+ $validator = Validator::make($request->all(), $rules, $messages);
+
+ if ($validator->fails()) {
+ return redirect()->route('admin.banner.edit')
+ ->withErrors($validator);
+ } else {
+ $params = $request->all();
+ unset($params['image']);
+ if ($request->has('image')) {
+ Storage::delete($banner->image);
+ $params['image'] = $request->file('image')->store('banners', 'public');
+ }
+
+ $banner->update($params);
+ return redirect()->route('admin.banner.index');
+ }
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param \App\Models\Banner $banner
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy(Banner $banner)
+ {
+ if (!empty($banner->image)) {
+ Storage::delete($banner->image);
+ }
+ $image->delete();
+ return redirect()->route('admin.banner.index');
+ }
+}
diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php
new file mode 100644
index 0000000..4577d73
--- /dev/null
+++ b/app/Http/Controllers/Admin/CategoryController.php
@@ -0,0 +1,86 @@
+middleware('guest')->except('logout');
+ }
+
+ //Форма входа
+ public function login() {
+ return view('auth.login');
+ }
+
+ // Аутентификация
+ public function autenticate(Request $request) {
+ $request->validate([
+ 'email' => 'required|string|email',
+ 'password' => 'required|string',
+ ]);
+
+ $credentials = $request->only('email', 'password');
+
+ if (Auth::attempt($credentials, $request->has('remember'))) {
+ if (is_null(Auth::user()->email_verified_at)){
+ Auth::logout();
+ return redirect()
+ ->route('auth.vefiry-message')
+ ->withErrors('Адрес почты не подтвержден');
+ }
+
+ return redirect()
+ ->route('user.index')
+ ->with('success', 'Вы вошли в личный кабинет.');
+ }
+
+ return redirect()
+ ->route('auth.login')
+ ->withErrors('Неверный логин или пароль!');
+ }
+
+ // Выход
+ public function logout() {
+ Auth::logout();
+ return redirect()->route('index')
+ ->with('success', 'Вы вышли из личного кабинета');
+ }
+}
diff --git a/app/Http/Controllers/RegisterController.php b/app/Http/Controllers/RegisterController.php
new file mode 100644
index 0000000..67d2faf
--- /dev/null
+++ b/app/Http/Controllers/RegisterController.php
@@ -0,0 +1,38 @@
+middleware('guest');
+ }
+
+ // Форма регистрации
+ public function register() {
+ return view('auth.register');
+ }
+
+ // Создание пользователя
+ public function create(Request $request) {
+ $request->validate([
+ 'name' => 'required|string|max:255',
+ 'email' => 'required|string|email|max:255|unique:users',
+ 'password' => 'required|string|min:8|confirmed',
+ ]);
+
+ User::create([
+ 'name' => $request->name,
+ 'email' => $request->email,
+ 'password' => Hash::make($request->password),
+ ]);
+
+ return redirect()
+ ->route('auth.login')
+ ->with('success', 'Вы успешно зарегистрировались');
+ }
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 704089a..67c7daf 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
- return route('login');
+ return route('auth.login');
}
}
}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index a2813a0..c04c2ee 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -23,7 +23,8 @@ class RedirectIfAuthenticated
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
- return redirect(RouteServiceProvider::HOME);
+ //return redirect(RouteServiceProvider::HOME);
+ return redirect()->route('user.index');
}
}
diff --git a/app/Models/Banner.php b/app/Models/Banner.php
index f007d2b..92389c9 100644
--- a/app/Models/Banner.php
+++ b/app/Models/Banner.php
@@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
class Banner extends Model
{
use HasFactory;
+
+ protected $fillable = ['title', 'text', 'image'];
}
diff --git a/public/css/style_table.css b/public/css/style_table.css
new file mode 100644
index 0000000..accac06
--- /dev/null
+++ b/public/css/style_table.css
@@ -0,0 +1,32 @@
+.table {
+ width: 100%;
+ border: none;
+ margin-bottom: 20px;
+}
+.table thead th {
+ font-weight: bold;
+ text-align: left;
+ border: none;
+ padding: 10px 15px;
+ background: #d8d8d8;
+ font-size: 14px;
+ border-left: 1px solid #ddd;
+ border-right: 1px solid #ddd;
+}
+.table tbody td {
+ text-align: left;
+ border-left: 1px solid #ddd;
+ border-right: 1px solid #ddd;
+ padding: 10px 15px;
+ font-size: 14px;
+ vertical-align: top;
+}
+.table thead tr th:first-child, .table tbody tr td:first-child {
+ border-left: none;
+}
+.table thead tr th:last-child, .table tbody tr td:last-child {
+ border-right: none;
+}
+.table tbody tr:nth-child(even){
+ background: #f3f3f3;
+}
diff --git a/resources/views/admin/banners/create.blade.php b/resources/views/admin/banners/create.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/admin/banners/edit.blade.php b/resources/views/admin/banners/edit.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/admin/banners/form.blade.php b/resources/views/admin/banners/form.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/admin/banners/index.blade.php b/resources/views/admin/banners/index.blade.php
new file mode 100644
index 0000000..188fef9
--- /dev/null
+++ b/resources/views/admin/banners/index.blade.php
@@ -0,0 +1,61 @@
+@extends('layout.admin', ['title' => 'Профиль пользователя'])
+
+@section('content')
+
+
+
+
+ Создать баннер
+
+
+
+
+
+ ID |
+ Фото |
+ Заголовок |
+ Дата создания |
+ Действия |
+
+
+
+ @if ($banners->count())
+ @foreach($banners as $banner)
+
+ {{ $banner->id }} |
+ if (empty($banner->image)) {?>Нет фото} else {?>
+
+
+ }?> |
+
+ {{ $banner->title }} |
+ {{ $banner->created_at }} |
+
+ |
+
+ @endforeach
+ @else
+
+ - |
+ - |
+ - |
+ - |
+ - |
+
+ @endif
+
+
+
+
+ {{ $banners->onEachSide(1)->links('catalogs.paginate') }}
+
+
+
+@endsection
diff --git a/resources/views/admin/profile.blade.php b/resources/views/admin/profile.blade.php
new file mode 100644
index 0000000..9b462aa
--- /dev/null
+++ b/resources/views/admin/profile.blade.php
@@ -0,0 +1,76 @@
+@extends('layout.admin', ['title' => 'Профиль пользователя'])
+
+@section('content')
+
+
+
+
Контактное лицо
+
{{ auth()->user()->name }}
+
+
+
Название компании
+
ООО “ВЕКПРОМ”
+
+
+
E-mail
+
{{ auth()->user()->email }}
+
+
+
Телефон
+
+7 965 - 333 - 44 - 44
+
+
+
+
+
+
+
+
+
+
+
Пароль успешно изменен
+
Хорошо
+
+@endsection
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
new file mode 100644
index 0000000..3c5505b
--- /dev/null
+++ b/resources/views/auth/login.blade.php
@@ -0,0 +1,33 @@
+@extends('layout.site', ['title' => 'Вход в личный кабинет'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php
new file mode 100644
index 0000000..8936151
--- /dev/null
+++ b/resources/views/auth/register.blade.php
@@ -0,0 +1,44 @@
+@extends('layout.site', ['title' => 'Регистрация'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/auth/test.blade.php b/resources/views/auth/test.blade.php
new file mode 100644
index 0000000..64a7a64
--- /dev/null
+++ b/resources/views/auth/test.blade.php
@@ -0,0 +1,10 @@
+@extends('layout.site', ['title' => 'Неудачный вход в личный кабинет'])
+
+@section('content')
+
+
+
Авторизация не пройдена!
+ Email не подтвержден.
+
+
+@endsection
diff --git a/resources/views/auth/verify-message.blade.php b/resources/views/auth/verify-message.blade.php
new file mode 100644
index 0000000..b287d13
--- /dev/null
+++ b/resources/views/auth/verify-message.blade.php
@@ -0,0 +1,9 @@
+@extends('layout.site', ['title' => 'Неудачный вход в личный кабинет'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/catalogs/paginate.blade.php b/resources/views/catalogs/paginate.blade.php
new file mode 100644
index 0000000..71c9676
--- /dev/null
+++ b/resources/views/catalogs/paginate.blade.php
@@ -0,0 +1,53 @@
+@if ($paginator->hasPages())
+
+@endif
diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php
new file mode 100644
index 0000000..f0dbaa2
--- /dev/null
+++ b/resources/views/layout/admin.blade.php
@@ -0,0 +1,592 @@
+
+
+
+
+
+
+
+
+ Vekprom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @if ($message = Session::get('success'))
+
+
+
+ {{ $message }}
+
+
+ @endif
+
+ @if ($errors->any())
+
+
+
+
+ @foreach ($errors->all() as $error)
+ - {{ $error }}
+ @endforeach
+
+
+
+ @endif
+
+
+
+
+
+ Личный кабинет
+
+
+
+
+
+
+ @yield('content')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/user/cabinet.blade.php b/resources/views/user/cabinet.blade.php
new file mode 100644
index 0000000..b9edf29
--- /dev/null
+++ b/resources/views/user/cabinet.blade.php
@@ -0,0 +1,112 @@
+@extends('layout.admin', ['title' => 'Личный кабинет'])
+
+@section('content')
+
+
+
+
+
+
Контактное лицо
+
{{ auth()->user()->name }}
+
+
+
Название компании
+
ООО “ВЕКПРОМ”
+
+
+
E-mail
+
{{ auth()->user()->email }}
+
+
+
Телефон
+
+7 965 - 333 - 44 - 44
+
+
+
+
+
+
+
+
+
Пароль успешно изменен
+
Хорошо
+
+
+
+
+
+
+
Заказ №:5726482949
+
Дата:28.02.2023
+
Сумма заказа:255 600 ₽
+
Посмотреть заказ
+
+
+
Ваши данные:
+
Алексей Витальевич Кржижановский
+
+7 965 114-44-44
+
123465gtyriejkk@mail.ru
+
+
+
+
+
+
+
+
+
+
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index 2eb6d84..7cac0c9 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,6 +1,13 @@
name('good');
//Упрощенная карточка товара
Route::get('simplegood',[MainController::class, 'simple_good'])->name('simplegood');
+Route::group([
+ 'as' => 'auth.', // имя маршрута, например auth.index
+ 'prefix' => 'auth', // префикс маршрута, например auth/index
+], function () {
+// Форма регистрации
+ Route::get('register', [RegisterController::class, 'register'])->name('register');
+
+// Создание пользователя
+ Route::post('register', [RegisterController::class, 'create'])->name('create');
+
+//Форма входа
+ Route::get('login', [LoginController::class, 'login'])->name('login');
+
+// аутентификация
+ Route::post('login', [LoginController::class, 'autenticate'])->name('auth');
+
+// выход
+ Route::get('logout', [LoginController::class, 'logout'])->name('logout');
+
+//Страница неудачной авторизации
+ Route::get('vefiry-message', function () {
+ return view('auth.test');
+ })->name('vefiry-message');
+
+});
+
+/*
+ * Личный кабинет пользователя
+ */
+Route::group([
+ 'as' => 'user.', // имя маршрута, например user.index
+ 'prefix' => 'user', // префикс маршрута, например user/index
+ //'namespace' => 'User', // пространство имен контроллеров
+ 'middleware' => ['auth'] // один или несколько посредников
+], function () {
+ // главная страница
+ Route::get('index', [AdminController::class, 'index'])->name('index');
+});
+
+Route::group([
+ 'as' => 'admin.', // имя маршрута, например admin.index
+ 'prefix' => 'admin', // префикс маршрута, например admin/index
+ //'namespace' => 'Admin', // пространство имен контроллеров
+ 'middleware' => ['auth'] // один или несколько посредников
+], function () {
+ /*
+ * CRUD-операции над баннерами
+ */
+ Route::resource('banner', BannerController::class, ['except' => ['show']]);
+
+ /*
+ * CRUD-операции над категориями
+ */
+ Route::resource('category', CategoryController::class, ['except' => ['show']]);
+
+ /*
+ * CRUD-операции над компанией
+ */
+ Route::resource('company', BannerController::class, ['except' => ['create', 'store', 'destroy', 'index']]);
+
+ /*
+ * CRUD-операции над категориями
+ */
+ Route::resource('goods', CategoryController::class, ['except' => ['show']]);
+
+ /*
+ * CRUD-операции над категориями
+ */
+ Route::resource('news', NewsController::class, ['except' => ['show']]);
+
+ /*
+ * CRUD-операции над категориями
+ */
+ Route::resource('project', ProjectController::class, ['except' => ['show']]);
+
+});