table with hotels
This commit is contained in:
@@ -8,17 +8,11 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Показать форму входа.
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('admin.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Обработать вход пользователя.
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
@@ -37,14 +31,14 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Выход пользователя.
|
||||
* Выход из системы.
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('admin.login.form');
|
||||
return view('admin.logout');
|
||||
}
|
||||
}
|
||||
|
||||
11
app/Http/Controllers/Admin/AvailabilityController.php
Normal file
11
app/Http/Controllers/Admin/AvailabilityController.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AvailabilityController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
11
app/Http/Controllers/Admin/BookingController.php
Normal file
11
app/Http/Controllers/Admin/BookingController.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -8,70 +8,51 @@ use Illuminate\Http\Request;
|
||||
|
||||
class HotelController extends Controller
|
||||
{
|
||||
/**
|
||||
* Показать список отелей.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$hotels = Hotel::all();
|
||||
return response()->view('admin/hotels/index', compact('hotels'));
|
||||
return view('admin.hotels.index', compact('hotels'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Показать форму создания отеля.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.hotels.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохранить новый отель.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'nullable|string',
|
||||
'phone' => 'nullable|string',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
Hotel::create($validated);
|
||||
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель добавлен!');
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель успешно добавлен!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Показать форму редактирования отеля.
|
||||
*/
|
||||
public function edit(Hotel $hotel)
|
||||
{
|
||||
return view('admin.hotels.edit', compact('hotel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновить отель.
|
||||
*/
|
||||
public function update(Request $request, Hotel $hotel)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'nullable|string',
|
||||
'phone' => 'nullable|string',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
$hotel->update($validated);
|
||||
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель обновлён!');
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель успешно обновлён!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Удалить отель.
|
||||
*/
|
||||
public function destroy(Hotel $hotel)
|
||||
{
|
||||
$hotel->delete();
|
||||
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель удалён!');
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель удалён.');
|
||||
}
|
||||
}
|
||||
}
|
||||
11
app/Http/Controllers/Admin/RoomTypeController.php
Normal file
11
app/Http/Controllers/Admin/RoomTypeController.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoomTypeController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class AdminAuthController extends Controller
|
||||
{
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$admin = Admin::where('email', $request->email)->first();
|
||||
|
||||
if (!$admin || !Hash::check($request->password, $admin->password)) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => ['The provided credentials are incorrect.'],
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'token' => $admin->createToken('admin-token')->plainTextToken,
|
||||
'admin' => $admin,
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
|
||||
return response()->json(['message' => 'Logged out successfully']);
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,16 @@ class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
// Установите путь к маршрутам
|
||||
$this->routesPath = base_path('routes');
|
||||
//$this->routesPath = base_path('routes');
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('web')
|
||||
->group($this->routesPath . '/web.php');
|
||||
//$this->routes(function () {
|
||||
//Route::middleware('web')
|
||||
//->group($this->routesPath . '/web.php');
|
||||
|
||||
Route::middleware(['web', 'auth'])
|
||||
->prefix('admin')
|
||||
->group($this->routesPath . '/admin.php');
|
||||
});
|
||||
//Route::middleware(['web', 'auth'])
|
||||
//->prefix('admin')
|
||||
//->group($this->routesPath . '/admin.php');
|
||||
//});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
32
resources/views/admin/hotels/create.blade.php
Normal file
32
resources/views/admin/hotels/create.blade.php
Normal file
@@ -0,0 +1,32 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div style="max-width: 600px;">
|
||||
<h1>Добавить отель</h1>
|
||||
|
||||
<form method="POST" action="{{ route('admin.hotels.store') }}">
|
||||
@csrf
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="name" style="display: block; margin-bottom: 6px; font-weight: 500;">Название *</label>
|
||||
<input type="text" name="name" id="name" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="address" style="display: block; margin-bottom: 6px; font-weight: 500;">Адрес</label>
|
||||
<textarea name="address" id="address" rows="3"
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;"></textarea>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label for="phone" style="display: block; margin-bottom: 6px; font-weight: 500;">Телефон</label>
|
||||
<input type="text" name="phone" id="phone"
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn">Сохранить</button>
|
||||
<a href="{{ route('admin.hotels.index') }}" class="btn" style="background: #6c757d; text-decoration: none; margin-left: 10px;">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
33
resources/views/admin/hotels/edit.blade.php
Normal file
33
resources/views/admin/hotels/edit.blade.php
Normal file
@@ -0,0 +1,33 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div style="max-width: 600px;">
|
||||
<h1>Редактировать отель</h1>
|
||||
|
||||
<form method="POST" action="{{ route('admin.hotels.update', $hotel) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="name" style="display: block; margin-bottom: 6px; font-weight: 500;">Название *</label>
|
||||
<input type="text" name="name" id="name" value="{{ old('name', $hotel->name) }}" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="address" style="display: block; margin-bottom: 6px; font-weight: 500;">Адрес</label>
|
||||
<textarea name="address" id="address" rows="3"
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">{{ old('address', $hotel->address) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label for="phone" style="display: block; margin-bottom: 6px; font-weight: 500;">Телефон</label>
|
||||
<input type="text" name="phone" id="phone" value="{{ old('phone', $hotel->phone) }}"
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn">Сохранить</button>
|
||||
<a href="{{ route('admin.hotels.index') }}" class="btn" style="background: #6c757d; text-decoration: none; margin-left: 10px;">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -1,45 +1,43 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div>
|
||||
<div>
|
||||
<h1>Отели</h1>
|
||||
|
||||
@if(session('success'))
|
||||
<div class="success">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
<a href="{{ route('admin.hotels.create') }}" class="btn" style="display: inline-block; margin-bottom: 20px;">Добавить отель</a>
|
||||
|
||||
@if($hotels->isEmpty())
|
||||
<p>Нет отелей.</p>
|
||||
@else
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Адрес</th>
|
||||
<th>Телефон</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($hotels as $hotel)
|
||||
<tr>
|
||||
<td>{{ $hotel->name }}</td>
|
||||
<td>{{ $hotel->address ?? '-' }}</td>
|
||||
<td>{{ $hotel->phone ?? '-' }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.hotels.edit', $hotel) }}" class="btn" style="background: #6c757d; margin-right: 6px;">Редактировать</a>
|
||||
<form action="{{ route('admin.hotels.destroy', $hotel) }}" method="POST" style="display: inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn" style="background: #aaa;" onclick="return confirm('Удалить отель?')">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
|
||||
<a href="{{ route('admin.hotels.create') }}" class="btn">Добавить отель</a>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Адрес</th>
|
||||
<th>Телефон</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($hotels as $hotel)
|
||||
<tr>
|
||||
<td>{{ $hotel->name }}</td>
|
||||
<td>{{ $hotel->address ?? '-' }}</td>
|
||||
<td>{{ $hotel->phone ?? '-' }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.hotels.edit', $hotel) }}" class="btn" style="background: #666;">Редактировать</a>
|
||||
<form action="{{ route('admin.hotels.destroy', $hotel) }}" method="POST" style="display: inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn" style="background: #aaa;" onclick="return confirm('Удалить отель?')">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -5,93 +5,118 @@
|
||||
<title>@yield('title', 'Админка')</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background: #fafafa;
|
||||
padding: 0;
|
||||
background-color: #f5f7fa;
|
||||
color: #333;
|
||||
}
|
||||
.container {
|
||||
.wrapper {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
header {
|
||||
background: #444;
|
||||
background-color: #4a4a4a;
|
||||
color: white;
|
||||
padding: 15px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 25px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
nav a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
margin-left: 20px;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
nav a:hover {
|
||||
background-color: #5a5a5a;
|
||||
}
|
||||
main {
|
||||
margin-top: 20px;
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||
}
|
||||
h1 {
|
||||
color: #333;
|
||||
border-bottom: 2px solid #ddd;
|
||||
padding-bottom: 10px;
|
||||
h1, h2, h3 {
|
||||
color: #2d2d2d;
|
||||
margin-top: 0;
|
||||
}
|
||||
.btn {
|
||||
display: inline-block;
|
||||
background: #888;
|
||||
background-color: #6c757d;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
text-decoration: none;
|
||||
margin-right: 10px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 0.95rem;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.btn:hover {
|
||||
background: #777;
|
||||
background-color: #5a6268;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 20px 0;
|
||||
background: white;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
th, td {
|
||||
padding: 12px;
|
||||
padding: 12px 15px;
|
||||
text-align: left;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
}
|
||||
th {
|
||||
background: #eee;
|
||||
font-weight: bold;
|
||||
background-color: #f1f1f1;
|
||||
font-weight: 600;
|
||||
color: #444;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background: #f9f9f9;
|
||||
tr:hover {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.success {
|
||||
background: #e0e0e0;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-left: 4px solid #999;
|
||||
.alert {
|
||||
padding: 12px;
|
||||
margin: 16px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.error {
|
||||
background: #ffdddd;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-left: 4px solid #cc0000;
|
||||
.alert-success {
|
||||
background-color: #e0f0e0;
|
||||
color: #2d5d2d;
|
||||
border-left: 4px solid #4caf50;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h2>Админка</h2>
|
||||
<nav>
|
||||
<a href="{{ route('admin.hotels.index') }}">Отели</a>
|
||||
<a href="{{ route('admin.logout') }}">Выйти</a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<nav>
|
||||
<a href="{{ route('admin.hotels.index') }}">Отели</a>
|
||||
<form action="{{ route('admin.logout') }}" method="POST" style="display: inline;">
|
||||
@csrf
|
||||
<button type="submit" style="background: none; border: none; color: white; cursor: pointer; padding: 6px 12px; border-radius: 4px;">
|
||||
Выйти
|
||||
</button>
|
||||
</form>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
@yield('content')
|
||||
</main>
|
||||
<main>
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,31 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Вход в админку</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; max-width: 400px; margin: 50px auto; }
|
||||
input { width: 100%; padding: 8px; margin: 5px 0; }
|
||||
button { width: 100%; padding: 10px; background: #404040; color: white; border: none; cursor: pointer; }
|
||||
.error { color: red; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Вход в админку</h1>
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div style="max-width: 400px; margin: 0 auto;">
|
||||
<h2>Вход в админку</h2>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="error">
|
||||
@foreach ($errors->all() as $error)
|
||||
<p>{{ $error }}</p>
|
||||
@endforeach
|
||||
<div class="alert alert-error" style="background: #ffeaea; color: #c0392b; padding: 12px; border-radius: 4px; border-left: 4px solid #e74c3c; margin-bottom: 20px;">
|
||||
Неверные данные.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.login') }}">
|
||||
@csrf
|
||||
<input type="email" name="email" placeholder="Email" required value="{{ old('email') }}">
|
||||
<input type="password" name="password" placeholder="Пароль" required>
|
||||
<button type="submit">Войти</button>
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="email" style="display: block; margin-bottom: 6px; font-weight: 500;">Email</label>
|
||||
<input type="email" name="email" id="email" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;"
|
||||
value="{{ old('email') }}">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label for="password" style="display: block; margin-bottom: 6px; font-weight: 500;">Пароль</label>
|
||||
<input type="password" name="password" id="password" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn" style="width: 100%;">Войти</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
@endsection
|
||||
9
resources/views/admin/logout.blade.php
Normal file
9
resources/views/admin/logout.blade.php
Normal file
@@ -0,0 +1,9 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div style="text-align: center; padding: 40px;">
|
||||
<h2>Вы вышли из системы</h2>
|
||||
<p>До скорой встречи!</p>
|
||||
<a href="{{ route('admin.login.form') }}" class="btn">Войти снова</a>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/login', [\App\Http\Controllers\Admin\AuthController::class, 'showLoginForm'])
|
||||
->name('admin.login.form');
|
||||
|
||||
Route::post('/login', [\App\Http\Controllers\Admin\AuthController::class, 'login'])
|
||||
->name('admin.login');
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/hotels', function () {
|
||||
return response()->view('admin.hotels.index');
|
||||
})->name('admin.hotels.index');
|
||||
|
||||
Route::post('/logout', [\App\Http\Controllers\Admin\AuthController::class, 'logout'])
|
||||
->name('admin.logout');
|
||||
});
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/hotels', [\App\Http\Controllers\Admin\HotelController::class, 'index'])->name('admin.hotels.index');
|
||||
Route::get('/hotels/create', [\App\Http\Controllers\Admin\HotelController::class, 'create'])->name('admin.hotels.create');
|
||||
Route::post('/hotels', [\App\Http\Controllers\Admin\HotelController::class, 'store'])->name('admin.hotels.store');
|
||||
Route::get('/hotels/{hotel}/edit', [\App\Http\Controllers\Admin\HotelController::class, 'edit'])->name('admin.hotels.edit');
|
||||
Route::put('/hotels/{hotel}', [\App\Http\Controllers\Admin\HotelController::class, 'update'])->name('admin.hotels.update');
|
||||
Route::delete('/hotels/{hotel}', [\App\Http\Controllers\Admin\HotelController::class, 'destroy'])->name('admin.hotels.destroy');
|
||||
|
||||
Route::post('/logout', [\App\Http\Controllers\Admin\AuthController::class, 'logout'])->name('admin.logout');
|
||||
});
|
||||
@@ -9,15 +9,18 @@ use App\Http\Controllers\RoomAvailabilityController;
|
||||
use App\Http\Controllers\BookingController;
|
||||
use App\Http\Controllers\InvoiceController;
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/hotels', [HotelController::class, 'store']);
|
||||
Route::get('/hotels', [HotelController::class, 'index']);
|
||||
Route::get('/hotels/{id}', [HotelController::class, 'show']);
|
||||
Route::put('/hotels/{id}', [HotelController::class, 'update']);
|
||||
Route::delete('/hotels/{id}', [HotelController::class, 'destroy']);
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/bookings/{id}/invoice', [InvoiceController::class, 'generate']);
|
||||
});
|
||||
|
||||
Route::get('/test', function () {
|
||||
return response()->success(['message' => 'Тест прошёл успешно!']);
|
||||
});
|
||||
|
||||
Route::post('/admin/login', [AdminAuthController::class, 'login']);
|
||||
Route::post('/admin/logout', [AdminAuthController::class, 'logout'])->middleware('auth:sanctum');
|
||||
|
||||
@@ -38,14 +41,6 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::get('/room_types', [RoomTypesController::class, 'index']);
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/hotels', [HotelController::class, 'store']);
|
||||
Route::get('/hotels', [HotelController::class, 'index']);
|
||||
Route::get('/hotels/{id}', [HotelController::class, 'show']);
|
||||
Route::put('/hotels/{id}', [HotelController::class, 'update']);
|
||||
Route::delete('/hotels/{id}', [HotelController::class, 'destroy']);
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::get('/hotels/{id}/rooms', [RoomTypeController::class, 'index']);
|
||||
Route::post('/hotels/{hotelId}/room-types', [RoomTypeController::class, 'store']);
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\Admin\HotelController;
|
||||
use App\Http\Controllers\Admin\AuthController;
|
||||
|
||||
// Гость → форма входа
|
||||
Route::get('/admin/login', [AuthController::class, 'showLoginForm'])->name('admin.login.form');
|
||||
Route::post('/admin/login', [AuthController::class, 'login'])->name('admin.login');
|
||||
|
||||
// Авторизованный → админка
|
||||
Route::middleware('auth')->prefix('admin')->group(function () {
|
||||
Route::get('/hotels', function () {
|
||||
return '<h1>Отели</h1><a href="/admin/logout">Выйти</a>';
|
||||
})->name('admin.hotels.index');
|
||||
Route::get('/hotels', [HotelController::class, 'index'])->name('admin.hotels.index');
|
||||
Route::get('/hotels/create', [HotelController::class, 'create'])->name('admin.hotels.create');
|
||||
Route::post('/hotels', [HotelController::class, 'store'])->name('admin.hotels.store');
|
||||
Route::get('/hotels/{hotel}/edit', [HotelController::class, 'edit'])->name('admin.hotels.edit');
|
||||
Route::put('/hotels/{hotel}', [HotelController::class, 'update'])->name('admin.hotels.update');
|
||||
Route::delete('/hotels/{hotel}', [HotelController::class, 'destroy'])->name('admin.hotels.destroy');
|
||||
|
||||
Route::post('/logout', [AuthController::class, 'logout'])->name('admin.logout');
|
||||
});
|
||||
|
||||
// → форма входа
|
||||
Route::get('/admin/login', [AuthController::class, 'showLoginForm'])->name('admin.login.form');
|
||||
Route::post('/admin/login', [AuthController::class, 'login'])->name('admin.login');
|
||||
|
||||
// → админка
|
||||
Route::middleware('auth')->prefix('admin')->group(function () {
|
||||
Route::get('/hotels', [HotelController::class, 'index'])->name('admin.hotels.index');
|
||||
Route::post('/logout', [AuthController::class, 'logout'])->name('admin.logout');
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user