diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..c5563e9
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,5 @@
+
+ RewriteEngine on
+ RewriteCond %{REQUEST_URI} !^public
+ RewriteRule ^(.*)$ public/$1 [L]
+
\ No newline at end of file
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
new file mode 100644
index 0000000..9b0ec4d
--- /dev/null
+++ b/app/Http/Controllers/AdminController.php
@@ -0,0 +1,13 @@
+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/MainController.php b/app/Http/Controllers/MainController.php
index 413a8a5..544f704 100644
--- a/app/Http/Controllers/MainController.php
+++ b/app/Http/Controllers/MainController.php
@@ -190,7 +190,7 @@ class MainController extends Controller
/*
* Категории каталога Аренда/Продажа/Бизнес
*/
- public function Category($cat) {
+ public function Category($cat, Request $request) {
switch ($cat) {
case 'arenda':
$title = "Аренда торговых помещениий";
@@ -211,7 +211,8 @@ class MainController extends Controller
}
$houses = House::with('areas')->
- where('format_house', '=', $format_house)->get();
+ where('format_house', '=', $format_house)->paginate(4)->appends(request()->query());
+ //->appends(request()->query());
return view('category_catalog', compact('title', 'houses'));
}
diff --git a/app/Http/Controllers/RegisterController.php b/app/Http/Controllers/RegisterController.php
new file mode 100644
index 0000000..d505086
--- /dev/null
+++ b/app/Http/Controllers/RegisterController.php
@@ -0,0 +1,39 @@
+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/resources/views/admin/index.blade.php b/resources/views/admin/index.blade.php
new file mode 100644
index 0000000..e2c0f81
--- /dev/null
+++ b/resources/views/admin/index.blade.php
@@ -0,0 +1,7 @@
+@extends('layout.site', ['title' => 'Личный кабинет'])
+
+@section('content')
+
Личный кабинет
+ Добрый день {{ auth()->user()->name }}!
+ Это личный кабинет пользователя сайта.
+@endsection
diff --git a/resources/views/auth/login-copy.blade.php b/resources/views/auth/login-copy.blade.php
new file mode 100644
index 0000000..a29a20a
--- /dev/null
+++ b/resources/views/auth/login-copy.blade.php
@@ -0,0 +1,45 @@
+@extends('layout.site', ['title' => 'Вход в личный кабинет'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
new file mode 100644
index 0000000..de276ae
--- /dev/null
+++ b/resources/views/auth/login.blade.php
@@ -0,0 +1,45 @@
+@extends('layout.site', ['title' => 'Вход в личный кабинет'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/auth/register-copy.blade.php b/resources/views/auth/register-copy.blade.php
new file mode 100644
index 0000000..80f3017
--- /dev/null
+++ b/resources/views/auth/register-copy.blade.php
@@ -0,0 +1,52 @@
+@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..d511064
--- /dev/null
+++ b/resources/views/auth/register.blade.php
@@ -0,0 +1,52 @@
+@extends('layout.site', ['title' => 'Регистрация'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/category_catalog.blade.php b/resources/views/category_catalog.blade.php
index 7c3a3e6..726c221 100644
--- a/resources/views/category_catalog.blade.php
+++ b/resources/views/category_catalog.blade.php
@@ -569,7 +569,10 @@
-->
diff --git a/resources/views/layout/site.blade.php b/resources/views/layout/site.blade.php
index cd6f5ce..4184110 100644
--- a/resources/views/layout/site.blade.php
+++ b/resources/views/layout/site.blade.php
@@ -79,6 +79,28 @@
+ @if ($message = Session::get('success'))
+
+
+ {{ $message }}
+
+ @endif
+
+ @if ($errors->any())
+
+
+
+ @foreach ($errors->all() as $error)
+ - {{ $error }}
+ @endforeach
+
+
+ @endif
+
@yield('filter')
diff --git a/routes/web.php b/routes/web.php
index 180d7ec..d2c8df6 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,7 +1,11 @@
name('category');
+
+
+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::group([
+ 'as' => 'user.', // имя маршрута, например user.index
+ 'prefix' => 'user', // префикс маршрута, например user/index
+ //'namespace' => 'User', // пространство имен контроллеров
+ 'middleware' => ['auth'] // один или несколько посредников
+], function () {
+ // главная страница
+ Route::get('index', [AdminController::class, 'index'])->name('index');
+});