Compare commits
8 Commits
66cddf3fb2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a448fce756 | |||
| 18aad4749f | |||
| ea511a00e6 | |||
| ff904abf49 | |||
| 2a83373b28 | |||
| e400b203b8 | |||
| 82f1f37af6 | |||
| 62100c42b0 |
8
RoomType::create([
Normal file
8
RoomType::create([
Normal file
@@ -0,0 +1,8 @@
|
||||
[90m= [39m[34;4mApp\Models\Hotel[39;24m {#5905
|
||||
[34mname[39m: "[32mMountain Lodge[39m",
|
||||
[34maddress[39m: "[32mAlpine Valley, Switzerland[39m",
|
||||
[34mupdated_at[39m: "[32m2026-01-23 22:51:26[39m",
|
||||
[34mcreated_at[39m: "[32m2026-01-23 22:51:26[39m",
|
||||
[34mid[39m: [35m30[39m,
|
||||
}
|
||||
|
||||
38
app/Http/Controllers/Admin/AuthController.php
Normal file
38
app/Http/Controllers/Admin/AuthController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('admin.login');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
if (Auth::attempt($credentials)) {
|
||||
$request->session()->regenerate();
|
||||
return redirect()->route('admin.hotels.index');
|
||||
}
|
||||
|
||||
return back()->withErrors(['email' => 'Неверные данные.']);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
return redirect()->route('admin.login.form')->with('success', 'Вы успешно вышли из системы.');
|
||||
}
|
||||
}
|
||||
55
app/Http/Controllers/Admin/AvailabilityController.php
Normal file
55
app/Http/Controllers/Admin/AvailabilityController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\RoomType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AvailabilityController extends Controller
|
||||
{
|
||||
public function calendar(RoomType $roomType)
|
||||
{
|
||||
$roomType->load('availabilities');
|
||||
|
||||
if (request()->ajax()) {
|
||||
return view('admin.availability._calendar', compact('roomType'))->render();
|
||||
}
|
||||
|
||||
return view('admin.availability.calendar', compact('roomType'));
|
||||
}
|
||||
|
||||
public function store(Request $request, RoomType $roomType)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date|after_or_equal:start_date',
|
||||
'is_available' => 'required|boolean',
|
||||
'price' => 'nullable|numeric|min=0',
|
||||
]);
|
||||
|
||||
$roomType->availabilities()
|
||||
->where('start_date', '<=', $validated['end_date'])
|
||||
->where('end_date', '>=', $validated['start_date'])
|
||||
->delete();
|
||||
|
||||
$roomType->availabilities()->create($validated);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Период сохранён.');
|
||||
}
|
||||
|
||||
public function destroy(\App\Models\Availability $availability)
|
||||
{
|
||||
$availability->delete();
|
||||
|
||||
if (request()->ajax()) {
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Период удалён.');
|
||||
}
|
||||
}
|
||||
71
app/Http/Controllers/Admin/HotelController.php
Normal file
71
app/Http/Controllers/Admin/HotelController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Hotel;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\RoomType;
|
||||
|
||||
class HotelController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$hotels = Hotel::all();
|
||||
return view('admin.hotels.index', compact('hotels'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('admin.hotels.create');
|
||||
}
|
||||
|
||||
public function calendar(Request $request, $hotelId)
|
||||
{
|
||||
$hotel = \App\Models\Hotel::findOrFail($hotelId);
|
||||
$roomTypes = RoomType::where('hotel_id', $hotelId)->with('availabilities')->get();
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('admin.hotels._calendar', compact('hotel', 'roomTypes'))->render();
|
||||
}
|
||||
|
||||
return view('admin.hotels.calendar', compact('hotel', 'roomTypes'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'nullable|string',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
Hotel::create($validated);
|
||||
|
||||
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|max:20',
|
||||
]);
|
||||
|
||||
$hotel->update($validated);
|
||||
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель успешно обновлён!');
|
||||
}
|
||||
|
||||
public function destroy(Hotel $hotel)
|
||||
{
|
||||
$hotel->delete();
|
||||
return redirect()->route('admin.hotels.index')->with('success', 'Отель удалён.');
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\RoomType;
|
||||
use App\Models\RoomAvailability;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'room_type_id' => 'required|exists:room_types,id',
|
||||
'check_in' => 'required|date|after_or_equal:today',
|
||||
'check_out' => 'required|date|after:check_in',
|
||||
'guest_name' => 'required|string|max:255',
|
||||
'guest_email' => 'required|email',
|
||||
'guest_phone' => 'required|string',
|
||||
'confirmation_type' => 'required|in:auto,manual',
|
||||
]);
|
||||
|
||||
$roomType = RoomType::findOrFail($validated['room_type_id']);
|
||||
|
||||
$dates = [];
|
||||
$currentDate = new \DateTime($validated['check_in']);
|
||||
$endDate = new \DateTime($validated['check_out']);
|
||||
|
||||
while ($currentDate < $endDate) {
|
||||
$dates[] = $currentDate->format('Y-m-d');
|
||||
$currentDate->modify('+1 day');
|
||||
}
|
||||
|
||||
$unavailableDates = RoomAvailability::where('room_type_id', $roomType->id)
|
||||
->whereIn('date', $dates)
|
||||
->where('is_available', false)
|
||||
->pluck('date')
|
||||
->toArray();
|
||||
|
||||
if (!empty($unavailableDates)) {
|
||||
throw ValidationException::withMessages([
|
||||
'check_in' => [
|
||||
'The following dates are not available: ' . implode(', ', $unavailableDates)
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$booking = Booking::create([
|
||||
'room_type_id' => $validated['room_type_id'],
|
||||
'check_in' => $validated['check_in'],
|
||||
'check_out' => $validated['check_out'],
|
||||
'guest_name' => $validated['guest_name'],
|
||||
'guest_email' => $validated['guest_email'],
|
||||
'guest_phone' => $validated['guest_phone'],
|
||||
'status' => $validated['confirmation_type'] === 'auto' ? 'confirmed' : 'pending',
|
||||
'confirmed_at' => $validated['confirmation_type'] === 'auto' ? now() : null,
|
||||
'created_by_user_id' => $request->user()->id, // ← ID админа
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json($booking, 201);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = \App\Models\Booking::with(['roomType', 'roomType.hotel']);
|
||||
|
||||
// Фильтр по статусу
|
||||
if ($request->has('status')) {
|
||||
$query->where('status', $request->status);
|
||||
}
|
||||
|
||||
// Фильтр по отелю
|
||||
if ($request->has('hotel_id')) {
|
||||
$query->whereHas('roomType.hotel', function ($q) use ($request) {
|
||||
$q->where('id', $request->hotel_id);
|
||||
});
|
||||
}
|
||||
|
||||
// Фильтр по дате заезда (от)
|
||||
if ($request->has('from')) {
|
||||
$query->where('check_in', '>=', $request->from);
|
||||
}
|
||||
|
||||
$query->orderBy('created_at', 'desc');
|
||||
|
||||
return response()->json($query->paginate(10));
|
||||
}
|
||||
public function confirm(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::findOrFail($id);
|
||||
|
||||
if ($booking->status !== 'pending') {
|
||||
return response()->json(['error' => 'Booking is not in pending status'], 400);
|
||||
}
|
||||
|
||||
$booking->update([
|
||||
'status' => 'confirmed',
|
||||
'confirmed_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json($booking);
|
||||
}
|
||||
|
||||
public function cancel(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::findOrFail($id);
|
||||
|
||||
if ($booking->status === 'cancelled') {
|
||||
return response()->json(['error' => 'Booking is already cancelled'], 400);
|
||||
}
|
||||
|
||||
$booking->update([
|
||||
'status' => 'cancelled',
|
||||
]);
|
||||
|
||||
return response()->json($booking);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Hotel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HotelController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Hotel::all();
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$hotel = Hotel::create($validated);
|
||||
|
||||
return response()->json($hotel, 201);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$hotel = Hotel::findOrFail($id);
|
||||
|
||||
return response()->json($hotel);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$hotel = Hotel::findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$hotel->update($validated);
|
||||
|
||||
return response()->json($hotel);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$hotel = Hotel::findOrFail($id);
|
||||
|
||||
|
||||
//if ($hotel->bookings()->exists()) {
|
||||
// return response()->json(['error' => 'Cannot delete hotel with bookings'], 400);
|
||||
//}
|
||||
|
||||
$hotel->delete();
|
||||
|
||||
return response()->json(['message' => 'Hotel deleted successfully']);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Orders extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Hamcrest\Number\OrderingComparison;
|
||||
use Illuminate\Container\Attributes\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Orders;
|
||||
|
||||
class OrdersController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Orders::all()->toJson);
|
||||
}
|
||||
public function create(Request $request)
|
||||
{
|
||||
$status = $request->get(key: 'status');
|
||||
$description = $request->get(key: 'description');
|
||||
|
||||
|
||||
|
||||
$order = new Order();
|
||||
$order ->status = $status;
|
||||
$order ->description = $description;
|
||||
|
||||
$order ->total = $request->get('total',0);
|
||||
$order ->save();
|
||||
|
||||
|
||||
|
||||
return response()->json($order->toJson());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\RoomType;
|
||||
use App\Models\RoomAvailability;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class RoomAvailabilityController extends Controller
|
||||
{
|
||||
public function index(Request $request, $roomTypeId)
|
||||
{
|
||||
$roomType = RoomType::findOrFail($roomTypeId);
|
||||
|
||||
$from = $request->query('from');
|
||||
$to = $request->query('to');
|
||||
|
||||
if (!$from || !$to) {
|
||||
throw ValidationException::withMessages([
|
||||
'from' => ['The from date is required.'],
|
||||
'to' => ['The to date is required.'],
|
||||
]);
|
||||
}
|
||||
|
||||
$fromDate = \DateTime::createFromFormat('Y-m-d', $from);
|
||||
$toDate = \DateTime::createFromFormat('Y-m-d', $to);
|
||||
|
||||
if (!$fromDate || !$toDate) {
|
||||
throw ValidationException::withMessages([
|
||||
'from' => ['Invalid from date format. Use YYYY-MM-DD.'],
|
||||
'to' => ['Invalid to date format. Use YYYY-MM-DD.'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($fromDate > $toDate) {
|
||||
throw ValidationException::withMessages([
|
||||
'from' => ['From date must be before to date.'],
|
||||
]);
|
||||
}
|
||||
|
||||
$availabilities = RoomAvailability::where('room_type_id', $roomTypeId)
|
||||
->whereBetween('date', [$from, $to])
|
||||
->orderBy('date')
|
||||
->get();
|
||||
|
||||
return response()->json($availabilities);
|
||||
}
|
||||
|
||||
public function bulkUpdate(Request $request, $roomTypeId)
|
||||
{
|
||||
$roomType = RoomType::findOrFail($roomTypeId);
|
||||
|
||||
$validated = $request->validate([
|
||||
'data' => 'required|array',
|
||||
'data.*.date' => 'required|date_format:Y-m-d|after_or_equal:today',
|
||||
'data.*.is_available' => 'required|boolean',
|
||||
'data.*.price_override' => 'nullable|numeric|min:0',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($validated['data'] as $item) {
|
||||
RoomAvailability::updateOrCreate(
|
||||
[
|
||||
'room_type_id' => $roomTypeId,
|
||||
'date' => $item['date'],
|
||||
],
|
||||
[
|
||||
'is_available' => $item['is_available'],
|
||||
'price_override' => $item['price_override'] ?? null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['message' => 'Availability updated successfully']);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Hotel;
|
||||
use App\Models\RoomType;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class RoomTypeController extends Controller
|
||||
{
|
||||
public function store(Request $request, $hotelId)
|
||||
{
|
||||
$hotel = Hotel::findOrFail($hotelId);
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'capacity' => 'required|integer|min:1',
|
||||
'base_price' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
$roomType = $hotel->roomTypes()->create($validated);
|
||||
|
||||
return response()->json($roomType, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$roomType = RoomType::findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'capacity' => 'required|integer|min:1',
|
||||
'base_price' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
$roomType->update($validated);
|
||||
|
||||
return response()->json($roomType);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$roomType = RoomType::findOrFail($id);
|
||||
|
||||
|
||||
if ($roomType->bookings()->exists()) {
|
||||
return response()->json(['error' => 'Cannot delete room type with active bookings'], 400);
|
||||
}
|
||||
|
||||
|
||||
if ($roomType->availabilities()->exists()) {
|
||||
return response()->json(['error' => 'Cannot delete room type with availability records'], 400);
|
||||
}
|
||||
|
||||
$roomType->delete();
|
||||
|
||||
return response()->json(['message' => 'Room type deleted successfully']);
|
||||
}
|
||||
|
||||
public function hotel()
|
||||
{
|
||||
return $this->belongsTo(Hotel::class);
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function availabilities()
|
||||
{
|
||||
return $this->hasMany(RoomAvailability::class);
|
||||
}
|
||||
}
|
||||
31
app/Models/Availability.php
Normal file
31
app/Models/Availability.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Availability extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'room_type_id',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'is_available',
|
||||
'price',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_available' => 'boolean',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'price' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function roomType()
|
||||
{
|
||||
return $this->belongsTo(RoomType::class);
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,15 @@ class Booking extends Model
|
||||
'guest_name',
|
||||
'guest_email',
|
||||
'guest_phone',
|
||||
'status',
|
||||
'confirmed_at',
|
||||
'is_confirmed',
|
||||
'total_price',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'check_in' => 'date',
|
||||
'check_out' => 'date',
|
||||
'confirmed_at' => 'datetime',
|
||||
'is_confirmed' => 'boolean',
|
||||
'total_price' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function roomType()
|
||||
|
||||
@@ -16,7 +16,7 @@ class Hotel extends Model
|
||||
|
||||
public function roomTypes()
|
||||
{
|
||||
return $this->hasMany(RoomType::class);
|
||||
return $this->hasMany(\App\Models\RoomType::class);
|
||||
}
|
||||
|
||||
//public function bookings()
|
||||
|
||||
@@ -12,8 +12,8 @@ class RoomType extends Model
|
||||
protected $fillable = [
|
||||
'hotel_id',
|
||||
'name',
|
||||
'capacity',
|
||||
'base_price',
|
||||
'description',
|
||||
'max_guests',
|
||||
];
|
||||
|
||||
public function hotel()
|
||||
@@ -21,13 +21,13 @@ class RoomType extends Model
|
||||
return $this->belongsTo(Hotel::class);
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function availabilities()
|
||||
{
|
||||
return $this->hasMany(RoomAvailability::class);
|
||||
return $this->hasMany(Availability::class);
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Booking::class);
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
42
app/Providers/EventServiceProvider.php
Normal file
42
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
32
app/Providers/ResponseMacroServiceProvider.php
Normal file
32
app/Providers/ResponseMacroServiceProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
class ResponseMacroServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
Response::macro('success', function ($data = null, $message = 'Success') {
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => $message,
|
||||
'data' => $data,
|
||||
]);
|
||||
});
|
||||
|
||||
Response::macro('error', function ($message = 'Error', $code = 400) {
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
], $code);
|
||||
});
|
||||
}
|
||||
}
|
||||
49
app/Providers/RouteServiceProvider.php
Normal file
49
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's route files.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $routesPath;
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
|
||||
// Route::middleware(['web', 'auth'])
|
||||
// ->prefix('admin')
|
||||
// ->group(base_path('routes/admin.php'));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\ResponseMacroServiceProvider::class,
|
||||
];
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/sanctum": "^4.2",
|
||||
"laravel/tinker": "^2.10.1"
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"laravel/ui": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/breeze": "*",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
|
||||
126
composer.lock
generated
126
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "343ecaac4a8b061c5430a046847047e7",
|
||||
"content-hash": "21efbfbbcf01cbe7cfa0cf7e625e9976",
|
||||
"packages": [
|
||||
{
|
||||
"name": "barryvdh/laravel-dompdf",
|
||||
@@ -1755,6 +1755,69 @@
|
||||
},
|
||||
"time": "2025-12-19T19:16:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/ui",
|
||||
"version": "v4.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/ui.git",
|
||||
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/ui/zipball/7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
|
||||
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/filesystem": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/support": "^9.21|^10.0|^11.0|^12.0",
|
||||
"illuminate/validation": "^9.21|^10.0|^11.0|^12.0",
|
||||
"php": "^8.0",
|
||||
"symfony/console": "^6.0|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^7.35|^8.15|^9.0|^10.0",
|
||||
"phpunit/phpunit": "^9.3|^10.4|^11.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Ui\\UiServiceProvider"
|
||||
]
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Ui\\": "src/",
|
||||
"Illuminate\\Foundation\\Auth\\": "auth-backend/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Laravel UI utilities and presets.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"ui"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/laravel/ui/tree/v4.6.1"
|
||||
},
|
||||
"time": "2025-01-28T15:15:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
"version": "2.8.0",
|
||||
@@ -6757,6 +6820,67 @@
|
||||
},
|
||||
"time": "2025-04-30T06:54:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/breeze",
|
||||
"version": "v2.3.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/breeze.git",
|
||||
"reference": "1a29c5792818bd4cddf70b5f743a227e02fbcfcd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/breeze/zipball/1a29c5792818bd4cddf70b5f743a227e02fbcfcd",
|
||||
"reference": "1a29c5792818bd4cddf70b5f743a227e02fbcfcd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^11.0|^12.0",
|
||||
"illuminate/filesystem": "^11.0|^12.0",
|
||||
"illuminate/support": "^11.0|^12.0",
|
||||
"illuminate/validation": "^11.0|^12.0",
|
||||
"php": "^8.2.0",
|
||||
"symfony/console": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/framework": "^11.0|^12.0",
|
||||
"orchestra/testbench-core": "^9.0|^10.0",
|
||||
"phpstan/phpstan": "^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Breeze\\BreezeServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Breeze\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Minimal Laravel authentication scaffolding with Blade and Tailwind.",
|
||||
"keywords": [
|
||||
"auth",
|
||||
"laravel"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/breeze/issues",
|
||||
"source": "https://github.com/laravel/breeze"
|
||||
},
|
||||
"time": "2025-07-18T18:49:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/pail",
|
||||
"version": "v1.2.4",
|
||||
|
||||
124
config/app.php
124
config/app.php
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| This value is the name of your application. This value is used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
| any other location as required by the application or its packages.
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -48,20 +49,22 @@ return [
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -73,37 +76,53 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
'locale' => 'en',
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Faker Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This locale will be used by the Faker PHP library when generating fake
|
||||
| data for your database seeds. For example, this will be used to get
|
||||
| localized telephone numbers, street address information and more.
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -119,8 +138,67 @@ return [
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
'driver' => 'file',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
// Laravel Framework Service Providers...
|
||||
Illuminate\Auth\AuthServiceProvider::class,
|
||||
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
Illuminate\Cache\CacheServiceProvider::class,
|
||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||
Illuminate\Cookie\CookieServiceProvider::class,
|
||||
Illuminate\Database\DatabaseServiceProvider::class,
|
||||
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||
Illuminate\Filesystem\FilesystemServiceProvider::class, // ← ОБЯЗАТЕЛЬНО!
|
||||
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||
Illuminate\Hashing\HashServiceProvider::class,
|
||||
Illuminate\Mail\MailServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Redis\RedisServiceProvider::class,
|
||||
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||
Illuminate\Session\SessionServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
|
||||
// Package Service Providers...
|
||||
|
||||
// Application Service Providers...
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'Example' => App\Facades\Example::class,
|
||||
])->toArray(),
|
||||
];
|
||||
|
||||
|
||||
19
config/cors.php
Normal file
19
config/cors.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
];
|
||||
@@ -1,41 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
'root' => storage_path('app'),
|
||||
],
|
||||
|
||||
'public' => [
|
||||
@@ -43,8 +14,6 @@ return [
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
@@ -56,25 +25,10 @@ return [
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
628
cription' => 'С панорамным видом',
Normal file
628
cription' => 'С панорамным видом',
Normal file
@@ -0,0 +1,628 @@
|
||||
|
||||
SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS
|
||||
|
||||
Commands marked with * may be preceded by a number, _N.
|
||||
Notes in parentheses indicate the behavior if _N is given.
|
||||
A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K.
|
||||
|
||||
h H Display this help.
|
||||
q :q Q :Q ZZ Exit.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
MMOOVVIINNGG
|
||||
|
||||
e ^E j ^N CR * Forward one line (or _N lines).
|
||||
y ^Y k ^K ^P * Backward one line (or _N lines).
|
||||
f ^F ^V SPACE * Forward one window (or _N lines).
|
||||
b ^B ESC-v * Backward one window (or _N lines).
|
||||
z * Forward one window (and set window to _N).
|
||||
w * Backward one window (and set window to _N).
|
||||
ESC-SPACE * Forward one window, but don't stop at end-of-file.
|
||||
d ^D * Forward one half-window (and set half-window to _N).
|
||||
u ^U * Backward one half-window (and set half-window to _N).
|
||||
ESC-) RightArrow * Right one half screen width (or _N positions).
|
||||
ESC-( LeftArrow * Left one half screen width (or _N positions).
|
||||
ESC-} ^RightArrow Right to last column displayed.
|
||||
ESC-{ ^LeftArrow Left to first column.
|
||||
F Forward forever; like "tail -f".
|
||||
ESC-F Like F but stop when search pattern is found.
|
||||
r ^R ^L Repaint screen.
|
||||
R Repaint screen, discarding buffered input.
|
||||
---------------------------------------------------
|
||||
Default "window" is the screen height.
|
||||
Default "half-window" is half of the screen height.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
SSEEAARRCCHHIINNGG
|
||||
|
||||
/_p_a_t_t_e_r_n * Search forward for (_N-th) matching line.
|
||||
?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line.
|
||||
n * Repeat previous search (for _N-th occurrence).
|
||||
N * Repeat previous search in reverse direction.
|
||||
ESC-n * Repeat previous search, spanning files.
|
||||
ESC-N * Repeat previous search, reverse dir. & spanning files.
|
||||
^O^N ^On * Search forward for (_N-th) OSC8 hyperlink.
|
||||
^O^P ^Op * Search backward for (_N-th) OSC8 hyperlink.
|
||||
^O^L ^Ol Jump to the currently selected OSC8 hyperlink.
|
||||
ESC-u Undo (toggle) search highlighting.
|
||||
ESC-U Clear search highlighting.
|
||||
&_p_a_t_t_e_r_n * Display only matching lines.
|
||||
---------------------------------------------------
|
||||
A search pattern may begin with one or more of:
|
||||
^N or ! Search for NON-matching lines.
|
||||
^E or * Search multiple files (pass thru END OF FILE).
|
||||
^F or @ Start search at FIRST file (for /) or last file (for ?).
|
||||
^K Highlight matches, but don't move (KEEP position).
|
||||
^R Don't use REGULAR EXPRESSIONS.
|
||||
^S _n Search for match in _n-th parenthesized subpattern.
|
||||
^W WRAP search if no match found.
|
||||
^L Enter next character literally into pattern.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
JJUUMMPPIINNGG
|
||||
|
||||
g < ESC-< * Go to first line in file (or line _N).
|
||||
G > ESC-> * Go to last line in file (or line _N).
|
||||
p % * Go to beginning of file (or _N percent into file).
|
||||
t * Go to the (_N-th) next tag.
|
||||
T * Go to the (_N-th) previous tag.
|
||||
{ ( [ * Find close bracket } ) ].
|
||||
} ) ] * Find open bracket { ( [.
|
||||
ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
|
||||
ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>.
|
||||
---------------------------------------------------
|
||||
Each "find close bracket" command goes forward to the close bracket
|
||||
matching the (_N-th) open bracket in the top line.
|
||||
Each "find open bracket" command goes backward to the open bracket
|
||||
matching the (_N-th) close bracket in the bottom line.
|
||||
|
||||
m_<_l_e_t_t_e_r_> Mark the current top line with <letter>.
|
||||
M_<_l_e_t_t_e_r_> Mark the current bottom line with <letter>.
|
||||
'_<_l_e_t_t_e_r_> Go to a previously marked position.
|
||||
'' Go to the previous position.
|
||||
^X^X Same as '.
|
||||
ESC-m_<_l_e_t_t_e_r_> Clear a mark.
|
||||
---------------------------------------------------
|
||||
A mark is any upper-case or lower-case letter.
|
||||
Certain marks are predefined:
|
||||
^ means beginning of the file
|
||||
$ means end of the file
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
CCHHAANNGGIINNGG FFIILLEESS
|
||||
|
||||
:e [_f_i_l_e] Examine a new file.
|
||||
^X^V Same as :e.
|
||||
:n * Examine the (_N-th) next file from the command line.
|
||||
:p * Examine the (_N-th) previous file from the command line.
|
||||
:x * Examine the first (or _N-th) file from the command line.
|
||||
^O^O Open the currently selected OSC8 hyperlink.
|
||||
:d Delete the current file from the command line list.
|
||||
= ^G :f Print current file name.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS
|
||||
|
||||
-_<_f_l_a_g_> Toggle a command line option [see OPTIONS below].
|
||||
--_<_n_a_m_e_> Toggle a command line option, by name.
|
||||
__<_f_l_a_g_> Display the setting of a command line option.
|
||||
___<_n_a_m_e_> Display the setting of an option, by name.
|
||||
+_c_m_d Execute the less cmd each time a new file is examined.
|
||||
|
||||
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
|
||||
#_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt.
|
||||
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
|
||||
s _f_i_l_e Save input to a file.
|
||||
v Edit the current file with $VISUAL or $EDITOR.
|
||||
V Print version number of "less".
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
OOPPTTIIOONNSS
|
||||
|
||||
Most options may be changed either on the command line,
|
||||
or from within less by using the - or -- command.
|
||||
Options may be given in one of two forms: either a single
|
||||
character preceded by a -, or a name preceded by --.
|
||||
|
||||
-? ........ --help
|
||||
Display help (from command line).
|
||||
-a ........ --search-skip-screen
|
||||
Search skips current screen.
|
||||
-A ........ --SEARCH-SKIP-SCREEN
|
||||
Search starts just after target line.
|
||||
-b [_N] .... --buffers=[_N]
|
||||
Number of buffers.
|
||||
-B ........ --auto-buffers
|
||||
Don't automatically allocate buffers for pipes.
|
||||
-c ........ --clear-screen
|
||||
Repaint by clearing rather than scrolling.
|
||||
-d ........ --dumb
|
||||
Dumb terminal.
|
||||
-D xx_c_o_l_o_r . --color=xx_c_o_l_o_r
|
||||
Set screen colors.
|
||||
-e -E .... --quit-at-eof --QUIT-AT-EOF
|
||||
Quit at end of file.
|
||||
-f ........ --force
|
||||
Force open non-regular files.
|
||||
-F ........ --quit-if-one-screen
|
||||
Quit if entire file fits on first screen.
|
||||
-g ........ --hilite-search
|
||||
Highlight only last match for searches.
|
||||
-G ........ --HILITE-SEARCH
|
||||
Don't highlight any matches for searches.
|
||||
-h [_N] .... --max-back-scroll=[_N]
|
||||
Backward scroll limit.
|
||||
-i ........ --ignore-case
|
||||
Ignore case in searches that do not contain uppercase.
|
||||
-I ........ --IGNORE-CASE
|
||||
Ignore case in all searches.
|
||||
-j [_N] .... --jump-target=[_N]
|
||||
Screen position of target lines.
|
||||
-J ........ --status-column
|
||||
Display a status column at left edge of screen.
|
||||
-k _f_i_l_e ... --lesskey-file=_f_i_l_e
|
||||
Use a compiled lesskey file.
|
||||
-K ........ --quit-on-intr
|
||||
Exit less in response to ctrl-C.
|
||||
-L ........ --no-lessopen
|
||||
Ignore the LESSOPEN environment variable.
|
||||
-m -M .... --long-prompt --LONG-PROMPT
|
||||
Set prompt style.
|
||||
-n ......... --line-numbers
|
||||
Suppress line numbers in prompts and messages.
|
||||
-N ......... --LINE-NUMBERS
|
||||
Display line number at start of each line.
|
||||
-o [_f_i_l_e] .. --log-file=[_f_i_l_e]
|
||||
Copy to log file (standard input only).
|
||||
-O [_f_i_l_e] .. --LOG-FILE=[_f_i_l_e]
|
||||
Copy to log file (unconditionally overwrite).
|
||||
-p _p_a_t_t_e_r_n . --pattern=[_p_a_t_t_e_r_n]
|
||||
Start at pattern (from command line).
|
||||
-P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t]
|
||||
Define new prompt.
|
||||
-q -Q .... --quiet --QUIET --silent --SILENT
|
||||
Quiet the terminal bell.
|
||||
-r -R .... --raw-control-chars --RAW-CONTROL-CHARS
|
||||
Output "raw" control characters.
|
||||
-s ........ --squeeze-blank-lines
|
||||
Squeeze multiple blank lines.
|
||||
-S ........ --chop-long-lines
|
||||
Chop (truncate) long lines rather than wrapping.
|
||||
-t _t_a_g .... --tag=[_t_a_g]
|
||||
Find a tag.
|
||||
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
|
||||
Use an alternate tags file.
|
||||
-u -U .... --underline-special --UNDERLINE-SPECIAL
|
||||
Change handling of backspaces, tabs and carriage returns.
|
||||
-V ........ --version
|
||||
Display the version number of "less".
|
||||
-w ........ --hilite-unread
|
||||
Highlight first new line after forward-screen.
|
||||
-W ........ --HILITE-UNREAD
|
||||
Highlight first new line after any forward movement.
|
||||
-x [_N[,...]] --tabs=[_N[,...]]
|
||||
Set tab stops.
|
||||
-X ........ --no-init
|
||||
Don't use termcap init/deinit strings.
|
||||
-y [_N] .... --max-forw-scroll=[_N]
|
||||
Forward scroll limit.
|
||||
-z [_N] .... --window=[_N]
|
||||
Set size of window.
|
||||
-" [_c[_c]] . --quotes=[_c[_c]]
|
||||
Set shell quote characters.
|
||||
-~ ........ --tilde
|
||||
Don't display tildes after end of file.
|
||||
-# [_N] .... --shift=[_N]
|
||||
Set horizontal scroll amount (0 = one half screen width).
|
||||
|
||||
--exit-follow-on-close
|
||||
Exit F command on a pipe when writer closes pipe.
|
||||
--file-size
|
||||
Automatically determine the size of the input file.
|
||||
--follow-name
|
||||
The F command changes files if the input file is renamed.
|
||||
--header=[_L[,_C[,_N]]]
|
||||
Use _L lines (starting at line _N) and _C columns as headers.
|
||||
--incsearch
|
||||
Search file as each pattern character is typed in.
|
||||
--intr=[_C]
|
||||
Use _C instead of ^X to interrupt a read.
|
||||
--lesskey-context=_t_e_x_t
|
||||
Use lesskey source file contents.
|
||||
--lesskey-src=_f_i_l_e
|
||||
Use a lesskey source file.
|
||||
--line-num-width=[_N]
|
||||
Set the width of the -N line number field to _N characters.
|
||||
--match-shift=[_N]
|
||||
Show at least _N characters to the left of a search match.
|
||||
--modelines=[_N]
|
||||
Read _N lines from the input file and look for vim modelines.
|
||||
--mouse
|
||||
Enable mouse input.
|
||||
--no-keypad
|
||||
Don't send termcap keypad init/deinit strings.
|
||||
--no-histdups
|
||||
Remove duplicates from command history.
|
||||
--no-number-headers
|
||||
Don't give line numbers to header lines.
|
||||
--no-search-header-lines
|
||||
Searches do not include header lines.
|
||||
--no-search-header-columns
|
||||
Searches do not include header columns.
|
||||
--no-search-headers
|
||||
Searches do not include header lines or columns.
|
||||
--no-vbell
|
||||
Disable the terminal's visual bell.
|
||||
--redraw-on-quit
|
||||
Redraw final screen when quitting.
|
||||
--rscroll=[_C]
|
||||
Set the character used to mark truncated lines.
|
||||
--save-marks
|
||||
Retain marks across invocations of less.
|
||||
--search-options=[EFKNRW-]
|
||||
Set default options for every search.
|
||||
--show-preproc-errors
|
||||
Display a message if preprocessor exits with an error status.
|
||||
--proc-backspace
|
||||
Process backspaces for bold/underline.
|
||||
--PROC-BACKSPACE
|
||||
Treat backspaces as control characters.
|
||||
--proc-return
|
||||
Delete carriage returns before newline.
|
||||
--PROC-RETURN
|
||||
Treat carriage returns as control characters.
|
||||
--proc-tab
|
||||
Expand tabs to spaces.
|
||||
--PROC-TAB
|
||||
Treat tabs as control characters.
|
||||
--status-col-width=[_N]
|
||||
Set the width of the -J status column to _N characters.
|
||||
--status-line
|
||||
Highlight or color the entire line containing a mark.
|
||||
--use-backslash
|
||||
Subsequent options use backslash as escape char.
|
||||
--use-color
|
||||
Enables colored text.
|
||||
--wheel-lines=[_N]
|
||||
Each click of the mouse wheel moves _N lines.
|
||||
--wordwrap
|
||||
Wrap lines at spaces.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
LLIINNEE EEDDIITTIINNGG
|
||||
|
||||
These keys can be used to edit text being entered
|
||||
on the "command line" at the bottom of the screen.
|
||||
|
||||
RightArrow ..................... ESC-l ... Move cursor right one character.
|
||||
LeftArrow ...................... ESC-h ... Move cursor left one character.
|
||||
ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word.
|
||||
ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word.
|
||||
HOME ........................... ESC-0 ... Move cursor to start of line.
|
||||
END ............................ ESC-$ ... Move cursor to end of line.
|
||||
BACKSPACE ................................ Delete char to left of cursor.
|
||||
DELETE ......................... ESC-x ... Delete char under cursor.
|
||||
ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor.
|
||||
ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor.
|
||||
ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line.
|
||||
UpArrow ........................ ESC-k ... Retrieve previous command line.
|
||||
DownArrow ...................... ESC-j ... Retrieve next command line.
|
||||
TAB ...................................... Complete filename & cycle.
|
||||
SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle.
|
||||
ctrl-L ................................... Complete filename, list all.
|
||||
|
||||
SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS
|
||||
|
||||
Commands marked with * may be preceded by a number, _N.
|
||||
Notes in parentheses indicate the behavior if _N is given.
|
||||
A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K.
|
||||
|
||||
h H Display this help.
|
||||
q :q Q :Q ZZ Exit.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
MMOOVVIINNGG
|
||||
|
||||
e ^E j ^N CR * Forward one line (or _N lines).
|
||||
y ^Y k ^K ^P * Backward one line (or _N lines).
|
||||
f ^F ^V SPACE * Forward one window (or _N lines).
|
||||
b ^B ESC-v * Backward one window (or _N lines).
|
||||
z * Forward one window (and set window to _N).
|
||||
w * Backward one window (and set window to _N).
|
||||
ESC-SPACE * Forward one window, but don't stop at end-of-file.
|
||||
d ^D * Forward one half-window (and set half-window to _N).
|
||||
u ^U * Backward one half-window (and set half-window to _N).
|
||||
ESC-) RightArrow * Right one half screen width (or _N positions).
|
||||
ESC-( LeftArrow * Left one half screen width (or _N positions).
|
||||
ESC-} ^RightArrow Right to last column displayed.
|
||||
ESC-{ ^LeftArrow Left to first column.
|
||||
F Forward forever; like "tail -f".
|
||||
ESC-F Like F but stop when search pattern is found.
|
||||
r ^R ^L Repaint screen.
|
||||
R Repaint screen, discarding buffered input.
|
||||
---------------------------------------------------
|
||||
Default "window" is the screen height.
|
||||
Default "half-window" is half of the screen height.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
SSEEAARRCCHHIINNGG
|
||||
|
||||
/_p_a_t_t_e_r_n * Search forward for (_N-th) matching line.
|
||||
?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line.
|
||||
n * Repeat previous search (for _N-th occurrence).
|
||||
N * Repeat previous search in reverse direction.
|
||||
ESC-n * Repeat previous search, spanning files.
|
||||
ESC-N * Repeat previous search, reverse dir. & spanning files.
|
||||
^O^N ^On * Search forward for (_N-th) OSC8 hyperlink.
|
||||
^O^P ^Op * Search backward for (_N-th) OSC8 hyperlink.
|
||||
^O^L ^Ol Jump to the currently selected OSC8 hyperlink.
|
||||
ESC-u Undo (toggle) search highlighting.
|
||||
ESC-U Clear search highlighting.
|
||||
&_p_a_t_t_e_r_n * Display only matching lines.
|
||||
---------------------------------------------------
|
||||
A search pattern may begin with one or more of:
|
||||
^N or ! Search for NON-matching lines.
|
||||
^E or * Search multiple files (pass thru END OF FILE).
|
||||
^F or @ Start search at FIRST file (for /) or last file (for ?).
|
||||
^K Highlight matches, but don't move (KEEP position).
|
||||
^R Don't use REGULAR EXPRESSIONS.
|
||||
^S _n Search for match in _n-th parenthesized subpattern.
|
||||
^W WRAP search if no match found.
|
||||
^L Enter next character literally into pattern.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
JJUUMMPPIINNGG
|
||||
|
||||
g < ESC-< * Go to first line in file (or line _N).
|
||||
G > ESC-> * Go to last line in file (or line _N).
|
||||
p % * Go to beginning of file (or _N percent into file).
|
||||
t * Go to the (_N-th) next tag.
|
||||
T * Go to the (_N-th) previous tag.
|
||||
{ ( [ * Find close bracket } ) ].
|
||||
} ) ] * Find open bracket { ( [.
|
||||
ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
|
||||
ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>.
|
||||
---------------------------------------------------
|
||||
Each "find close bracket" command goes forward to the close bracket
|
||||
matching the (_N-th) open bracket in the top line.
|
||||
Each "find open bracket" command goes backward to the open bracket
|
||||
matching the (_N-th) close bracket in the bottom line.
|
||||
|
||||
m_<_l_e_t_t_e_r_> Mark the current top line with <letter>.
|
||||
M_<_l_e_t_t_e_r_> Mark the current bottom line with <letter>.
|
||||
'_<_l_e_t_t_e_r_> Go to a previously marked position.
|
||||
'' Go to the previous position.
|
||||
^X^X Same as '.
|
||||
ESC-m_<_l_e_t_t_e_r_> Clear a mark.
|
||||
---------------------------------------------------
|
||||
A mark is any upper-case or lower-case letter.
|
||||
Certain marks are predefined:
|
||||
^ means beginning of the file
|
||||
$ means end of the file
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
CCHHAANNGGIINNGG FFIILLEESS
|
||||
|
||||
:e [_f_i_l_e] Examine a new file.
|
||||
^X^V Same as :e.
|
||||
:n * Examine the (_N-th) next file from the command line.
|
||||
:p * Examine the (_N-th) previous file from the command line.
|
||||
:x * Examine the first (or _N-th) file from the command line.
|
||||
^O^O Open the currently selected OSC8 hyperlink.
|
||||
:d Delete the current file from the command line list.
|
||||
= ^G :f Print current file name.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS
|
||||
|
||||
-_<_f_l_a_g_> Toggle a command line option [see OPTIONS below].
|
||||
--_<_n_a_m_e_> Toggle a command line option, by name.
|
||||
__<_f_l_a_g_> Display the setting of a command line option.
|
||||
___<_n_a_m_e_> Display the setting of an option, by name.
|
||||
+_c_m_d Execute the less cmd each time a new file is examined.
|
||||
|
||||
!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
|
||||
#_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt.
|
||||
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
|
||||
s _f_i_l_e Save input to a file.
|
||||
v Edit the current file with $VISUAL or $EDITOR.
|
||||
V Print version number of "less".
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
OOPPTTIIOONNSS
|
||||
|
||||
Most options may be changed either on the command line,
|
||||
or from within less by using the - or -- command.
|
||||
Options may be given in one of two forms: either a single
|
||||
character preceded by a -, or a name preceded by --.
|
||||
|
||||
-? ........ --help
|
||||
Display help (from command line).
|
||||
-a ........ --search-skip-screen
|
||||
Search skips current screen.
|
||||
-A ........ --SEARCH-SKIP-SCREEN
|
||||
Search starts just after target line.
|
||||
-b [_N] .... --buffers=[_N]
|
||||
Number of buffers.
|
||||
-B ........ --auto-buffers
|
||||
Don't automatically allocate buffers for pipes.
|
||||
-c ........ --clear-screen
|
||||
Repaint by clearing rather than scrolling.
|
||||
-d ........ --dumb
|
||||
Dumb terminal.
|
||||
-D xx_c_o_l_o_r . --color=xx_c_o_l_o_r
|
||||
Set screen colors.
|
||||
-e -E .... --quit-at-eof --QUIT-AT-EOF
|
||||
Quit at end of file.
|
||||
-f ........ --force
|
||||
Force open non-regular files.
|
||||
-F ........ --quit-if-one-screen
|
||||
Quit if entire file fits on first screen.
|
||||
-g ........ --hilite-search
|
||||
Highlight only last match for searches.
|
||||
-G ........ --HILITE-SEARCH
|
||||
Don't highlight any matches for searches.
|
||||
-h [_N] .... --max-back-scroll=[_N]
|
||||
Backward scroll limit.
|
||||
-i ........ --ignore-case
|
||||
Ignore case in searches that do not contain uppercase.
|
||||
-I ........ --IGNORE-CASE
|
||||
Ignore case in all searches.
|
||||
-j [_N] .... --jump-target=[_N]
|
||||
Screen position of target lines.
|
||||
-J ........ --status-column
|
||||
Display a status column at left edge of screen.
|
||||
-k _f_i_l_e ... --lesskey-file=_f_i_l_e
|
||||
Use a compiled lesskey file.
|
||||
-K ........ --quit-on-intr
|
||||
Exit less in response to ctrl-C.
|
||||
-L ........ --no-lessopen
|
||||
Ignore the LESSOPEN environment variable.
|
||||
-m -M .... --long-prompt --LONG-PROMPT
|
||||
Set prompt style.
|
||||
-n ......... --line-numbers
|
||||
Suppress line numbers in prompts and messages.
|
||||
-N ......... --LINE-NUMBERS
|
||||
Display line number at start of each line.
|
||||
-o [_f_i_l_e] .. --log-file=[_f_i_l_e]
|
||||
Copy to log file (standard input only).
|
||||
-O [_f_i_l_e] .. --LOG-FILE=[_f_i_l_e]
|
||||
Copy to log file (unconditionally overwrite).
|
||||
-p _p_a_t_t_e_r_n . --pattern=[_p_a_t_t_e_r_n]
|
||||
Start at pattern (from command line).
|
||||
-P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t]
|
||||
Define new prompt.
|
||||
-q -Q .... --quiet --QUIET --silent --SILENT
|
||||
Quiet the terminal bell.
|
||||
-r -R .... --raw-control-chars --RAW-CONTROL-CHARS
|
||||
Output "raw" control characters.
|
||||
-s ........ --squeeze-blank-lines
|
||||
Squeeze multiple blank lines.
|
||||
-S ........ --chop-long-lines
|
||||
Chop (truncate) long lines rather than wrapping.
|
||||
-t _t_a_g .... --tag=[_t_a_g]
|
||||
Find a tag.
|
||||
-T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e]
|
||||
Use an alternate tags file.
|
||||
-u -U .... --underline-special --UNDERLINE-SPECIAL
|
||||
Change handling of backspaces, tabs and carriage returns.
|
||||
-V ........ --version
|
||||
Display the version number of "less".
|
||||
-w ........ --hilite-unread
|
||||
Highlight first new line after forward-screen.
|
||||
-W ........ --HILITE-UNREAD
|
||||
Highlight first new line after any forward movement.
|
||||
-x [_N[,...]] --tabs=[_N[,...]]
|
||||
Set tab stops.
|
||||
-X ........ --no-init
|
||||
Don't use termcap init/deinit strings.
|
||||
-y [_N] .... --max-forw-scroll=[_N]
|
||||
Forward scroll limit.
|
||||
-z [_N] .... --window=[_N]
|
||||
Set size of window.
|
||||
-" [_c[_c]] . --quotes=[_c[_c]]
|
||||
Set shell quote characters.
|
||||
-~ ........ --tilde
|
||||
Don't display tildes after end of file.
|
||||
-# [_N] .... --shift=[_N]
|
||||
Set horizontal scroll amount (0 = one half screen width).
|
||||
|
||||
--exit-follow-on-close
|
||||
Exit F command on a pipe when writer closes pipe.
|
||||
--file-size
|
||||
Automatically determine the size of the input file.
|
||||
--follow-name
|
||||
The F command changes files if the input file is renamed.
|
||||
--header=[_L[,_C[,_N]]]
|
||||
Use _L lines (starting at line _N) and _C columns as headers.
|
||||
--incsearch
|
||||
Search file as each pattern character is typed in.
|
||||
--intr=[_C]
|
||||
Use _C instead of ^X to interrupt a read.
|
||||
--lesskey-context=_t_e_x_t
|
||||
Use lesskey source file contents.
|
||||
--lesskey-src=_f_i_l_e
|
||||
Use a lesskey source file.
|
||||
--line-num-width=[_N]
|
||||
Set the width of the -N line number field to _N characters.
|
||||
--match-shift=[_N]
|
||||
Show at least _N characters to the left of a search match.
|
||||
--modelines=[_N]
|
||||
Read _N lines from the input file and look for vim modelines.
|
||||
--mouse
|
||||
Enable mouse input.
|
||||
--no-keypad
|
||||
Don't send termcap keypad init/deinit strings.
|
||||
--no-histdups
|
||||
Remove duplicates from command history.
|
||||
--no-number-headers
|
||||
Don't give line numbers to header lines.
|
||||
--no-search-header-lines
|
||||
Searches do not include header lines.
|
||||
--no-search-header-columns
|
||||
Searches do not include header columns.
|
||||
--no-search-headers
|
||||
Searches do not include header lines or columns.
|
||||
--no-vbell
|
||||
Disable the terminal's visual bell.
|
||||
--redraw-on-quit
|
||||
Redraw final screen when quitting.
|
||||
--rscroll=[_C]
|
||||
Set the character used to mark truncated lines.
|
||||
--save-marks
|
||||
Retain marks across invocations of less.
|
||||
--search-options=[EFKNRW-]
|
||||
Set default options for every search.
|
||||
--show-preproc-errors
|
||||
Display a message if preprocessor exits with an error status.
|
||||
--proc-backspace
|
||||
Process backspaces for bold/underline.
|
||||
--PROC-BACKSPACE
|
||||
Treat backspaces as control characters.
|
||||
--proc-return
|
||||
Delete carriage returns before newline.
|
||||
--PROC-RETURN
|
||||
Treat carriage returns as control characters.
|
||||
--proc-tab
|
||||
Expand tabs to spaces.
|
||||
--PROC-TAB
|
||||
Treat tabs as control characters.
|
||||
--status-col-width=[_N]
|
||||
Set the width of the -J status column to _N characters.
|
||||
--status-line
|
||||
Highlight or color the entire line containing a mark.
|
||||
--use-backslash
|
||||
Subsequent options use backslash as escape char.
|
||||
--use-color
|
||||
Enables colored text.
|
||||
--wheel-lines=[_N]
|
||||
Each click of the mouse wheel moves _N lines.
|
||||
--wordwrap
|
||||
Wrap lines at spaces.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
LLIINNEE EEDDIITTIINNGG
|
||||
|
||||
These keys can be used to edit text being entered
|
||||
on the "command line" at the bottom of the screen.
|
||||
|
||||
RightArrow ..................... ESC-l ... Move cursor right one character.
|
||||
LeftArrow ...................... ESC-h ... Move cursor left one character.
|
||||
ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word.
|
||||
ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word.
|
||||
HOME ........................... ESC-0 ... Move cursor to start of line.
|
||||
END ............................ ESC-$ ... Move cursor to end of line.
|
||||
BACKSPACE ................................ Delete char to left of cursor.
|
||||
DELETE ......................... ESC-x ... Delete char under cursor.
|
||||
ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor.
|
||||
ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor.
|
||||
ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line.
|
||||
UpArrow ........................ ESC-k ... Retrieve previous command line.
|
||||
DownArrow ...................... ESC-j ... Retrieve next command line.
|
||||
TAB ...................................... Complete filename & cycle.
|
||||
SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle.
|
||||
ctrl-L ................................... Complete filename, list all.
|
||||
@@ -4,27 +4,21 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
class CreateHotelsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
public function up()
|
||||
{
|
||||
Schema::create('hotels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('address');
|
||||
$table->text('description')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('hotels');
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('hotel_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->integer('capacity');
|
||||
$table->integer('capacity')->nullable()->default(2)->change();
|
||||
$table->decimal('base_price', 10, 2);
|
||||
$table->timestamps();
|
||||
});
|
||||
@@ -24,8 +24,10 @@ return new class extends Migration
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('room_types');
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->integer('capacity')->default(2)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('room_availability', function (Blueprint $table) {
|
||||
Schema::create('room_availabilities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('date');
|
||||
|
||||
@@ -9,24 +9,21 @@ return new class extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('booking_number')->nullable();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('check_in');
|
||||
$table->date('check_out');
|
||||
$table->string('guest_name');
|
||||
$table->string('guest_email')->nullable();
|
||||
$table->string('guest_phone')->nullable();
|
||||
$table->enum('status', ['pending', 'confirmed', 'cancelled', 'completed'])->default('pending');
|
||||
$table->enum('confirmation_type', ['auto', 'manual'])->default('auto');
|
||||
$table->unsignedBigInteger('created_by_user_id')->nullable();
|
||||
$table->timestamp('confirmed_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('check_in');
|
||||
$table->date('check_out');
|
||||
$table->string('guest_name');
|
||||
$table->string('guest_email');
|
||||
$table->string('guest_phone')->nullable();
|
||||
$table->boolean('is_confirmed')->default(false);
|
||||
$table->decimal('total_price', 10, 2)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDefaultPhoneToUsersTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('phone')->default('')->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('phone')->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('availabilities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('room_type_id')->constrained()->onDelete('cascade');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->boolean('is_available')->default(true);
|
||||
$table->decimal('price', 8, 2)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('availabilities');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->after('name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->integer('max_guests')->default(2)->after('description');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->dropColumn('max_guests');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
// Изменяем capacity: делаем nullable и добавляем default
|
||||
$table->integer('capacity')->nullable()->default(2)->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->integer('capacity')->default(2)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
// Изменяем base_price: делаем nullable и добавляем default
|
||||
$table->decimal('base_price', 8, 2)->nullable()->default(5000.00)->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('room_types', function (Blueprint $table) {
|
||||
$table->decimal('base_price', 8, 2)->default(5000.00)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -2,24 +2,66 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Admin;
|
||||
use App\Models\Hotel;
|
||||
use App\Models\RoomType;
|
||||
use App\Models\RoomAvailability;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
// Админ
|
||||
$admin = Admin::firstOrCreate([
|
||||
'email' => 'admin@hotels.ru',
|
||||
], [
|
||||
'name' => 'Admin User',
|
||||
'password' => Hash::make('password'),
|
||||
]);
|
||||
|
||||
// Отель
|
||||
$hotel = Hotel::create([
|
||||
'name' => 'Grand Hotel',
|
||||
'address' => '123 Main St',
|
||||
]);
|
||||
|
||||
$roomType1 = RoomType::create([
|
||||
'hotel_id' => $hotel->id,
|
||||
'name' => 'Двухместный',
|
||||
'capacity' => 2,
|
||||
'base_price' => 5000,
|
||||
]);
|
||||
|
||||
$roomType2 = RoomType::create([
|
||||
'hotel_id' => $hotel->id,
|
||||
'name' => 'Люкс',
|
||||
'capacity' => 4,
|
||||
'base_price' => 10000,
|
||||
]);
|
||||
|
||||
$startDate = now()->startOfDay();
|
||||
$endDate = now()->addDays(30)->startOfDay();
|
||||
|
||||
for ($date = $startDate; $date <= $endDate; $date->modify('+1 day')) {
|
||||
RoomAvailability::create([
|
||||
'room_type_id' => $roomType1->id,
|
||||
'date' => $date->format('Y-m-d'),
|
||||
'is_available' => true,
|
||||
'price_override' => null,
|
||||
]);
|
||||
|
||||
RoomAvailability::create([
|
||||
'room_type_id' => $roomType2->id,
|
||||
'date' => $date->format('Y-m-d'),
|
||||
'is_available' => true,
|
||||
'price_override' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
2226
package-lock.json
generated
2226
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -1,17 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"axios": "^1.11.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^7.0.7"
|
||||
}
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"laravel-vite-plugin": "^1.0",
|
||||
"vite": "^5.0"
|
||||
}
|
||||
}
|
||||
|
||||
97
resources/views/admin/hotels/_calendar.blade.php
Normal file
97
resources/views/admin/hotels/_calendar.blade.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<div>
|
||||
@if($roomTypes->isEmpty())
|
||||
<p>Нет типов номеров. <a href="{{ route('admin.room-types.create') }}">Создать тип номера</a></p>
|
||||
@else
|
||||
@foreach($roomTypes as $type)
|
||||
<div style="margin-bottom: 25px; padding: 15px; border: 1px solid #eee; border-radius: 6px;">
|
||||
<h3>{{ $type->name }}</h3>
|
||||
|
||||
<!-- Форма добавления периода -->
|
||||
<form class="availability-form" data-room-type-id="{{ $type->id }}" style="margin-bottom: 15px;">
|
||||
@csrf
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 10px;">
|
||||
<input type="date" name="start_date" required style="flex:1; padding:6px; border:1px solid #ccc; border-radius:4px;">
|
||||
<input type="date" name="end_date" required style="flex:1; padding:6px; border:1px solid #ccc; border-radius:4px;">
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<label>
|
||||
<input type="checkbox" name="is_available" value="1" checked> Доступен
|
||||
</label>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<input type="number" name="price" step="0.01" placeholder="Цена" style="width:100%; padding:6px; border:1px solid #ccc; border-radius:4px;">
|
||||
</div>
|
||||
<button type="submit" class="btn" style="padding:6px 12px;">Сохранить</button>
|
||||
</form>
|
||||
|
||||
<!-- Список периодов -->
|
||||
@if($type->availabilities->isEmpty())
|
||||
<p>Нет периодов.</p>
|
||||
@else
|
||||
<table style="width:100%; font-size:0.9rem;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>С</th>
|
||||
<th>По</th>
|
||||
<th>Статус</th>
|
||||
<th>Цена</th>
|
||||
<th>Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($type->availabilities as $period)
|
||||
<tr>
|
||||
<td>{{ $period->start_date }}</td>
|
||||
<td>{{ $period->end_date }}</td>
|
||||
<td>
|
||||
@if($period->is_available)
|
||||
<span style="color:green;">Доступен</span>
|
||||
@else
|
||||
<span style="color:red;">Недоступен</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $period->price ? number_format($period->price, 2) : '-' }}</td>
|
||||
<td>
|
||||
<form method="POST" action="/admin/availability/{{ $period->id }}" style="display:inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger" style="padding:4px 8px; font-size:0.8rem;" onclick="return confirm('Удалить период?')">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('.availability-form').forEach(form => {
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(form);
|
||||
const roomTypeId = form.dataset.roomTypeId;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/admin/room-types/${roomTypeId}/availability`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
location.reload(); // Обновить модалку
|
||||
} else {
|
||||
alert('Ошибка сохранения');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Ошибка сети');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
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: #6a1b9a; margin-left: 10px;">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsections
|
||||
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: #6a1b9a; margin-left: 10px;">Отмена</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
88
resources/views/admin/hotels/index.blade.php
Normal file
88
resources/views/admin/hotels/index.blade.php
Normal file
@@ -0,0 +1,88 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div>
|
||||
<h1>Отели</h1>
|
||||
|
||||
<a href="{{ route('admin.hotels.create') }}" class="btn">Добавить отель</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="margin-right: 5px;">
|
||||
Редактировать
|
||||
</a>
|
||||
<form action="{{ route('admin.hotels.destroy', $hotel) }}" method="POST" style="display: inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger" style="margin-right: 5px;" onclick="return confirm('Удалить отель?')">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
<!-- Кнопка шахматки -->
|
||||
<button type="button" class="btn btn-secondary open-calendar-modal" data-hotel-id="{{ $hotel->id }}">
|
||||
Календарь
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно для шахматки -->
|
||||
<div id="calendarModal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:1000;">
|
||||
<div style="background:white;margin:50px auto;padding:25px;border-radius:8px;max-width:800px;box-shadow:0 4px 20px rgba(0,0,0,0.3);">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;">
|
||||
<h2>Доступные даты: <span id="modalHotelName"></span></h2>
|
||||
<button id="closeCalendarModal" style="background:none;border:none;font-size:1.5rem;cursor:pointer;">×</button>
|
||||
</div>
|
||||
<div id="calendarModalContent">Загрузка...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const modal = document.getElementById('calendarModal');
|
||||
const closeModalBtn = document.getElementById('closeCalendarModal');
|
||||
|
||||
document.querySelectorAll('.open-calendar-modal').forEach(button => {
|
||||
button.addEventListener('click', async function () {
|
||||
const hotelId = this.dataset.hotelId;
|
||||
const hotelName = this.closest('tr').querySelector('td:first-child').textContent;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/admin/hotels/${hotelId}/calendar`, {
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
});
|
||||
document.getElementById('modalHotelName').textContent = hotelName;
|
||||
document.getElementById('calendarModalContent').innerHTML = await response.text();
|
||||
modal.style.display = 'block';
|
||||
} catch (e) {
|
||||
alert('Ошибка загрузки шахматки');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
closeModalBtn.onclick = () => modal.style.display = 'none';
|
||||
window.onclick = (e) => { if (e.target === modal) modal.style.display = 'none'; };
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
91
resources/views/admin/layout.blade.php
Normal file
91
resources/views/admin/layout.blade.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>@yield('title', 'Админка')</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f5f7fa;
|
||||
color: #333;
|
||||
}
|
||||
.wrapper {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
header {
|
||||
background-color: #4a148c;
|
||||
color: white;
|
||||
padding: 15px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 25px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
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: #6a1b9a;
|
||||
}
|
||||
main {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||
}
|
||||
.btn {
|
||||
display: inline-block;
|
||||
background-color: #4a148c;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 0.95rem;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.btn:hover { background-color: #6a1b9a; }
|
||||
.btn-secondary { background-color: #7b1fa2; }
|
||||
.btn-secondary:hover { background-color: #9c27b0; }
|
||||
.btn-danger { background-color: #000000; }
|
||||
.btn-danger:hover { background-color: #212121; }
|
||||
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
||||
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eaeaea; }
|
||||
th { background-color: #f1f1f1; font-weight: 600; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<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;">Выйти</button>
|
||||
</form>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
@if(session('success'))
|
||||
<div style="padding:12px;background:#e0f0e0;color:#2d5d2d;border-left:4px solid #4caf50;margin:16px 0;border-radius:4px;">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
30
resources/views/admin/login.blade.php
Normal file
30
resources/views/admin/login.blade.php
Normal file
@@ -0,0 +1,30 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<div style="max-width: 400px; margin: 0 auto;">
|
||||
<h2>Вход в админку</h2>
|
||||
|
||||
@if ($errors->any())
|
||||
<div style="background: #ffeaea; color: #c0392b; padding: 12px; border-radius: 4px; margin-bottom: 20px;">
|
||||
Неверные данные.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.login') }}">
|
||||
@csrf
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label for="email" style="display: block; margin-bottom: 6px;">Email</label>
|
||||
<input type="email" name="email" id="email" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px;" value="{{ old('email') }}">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label for="password" style="display: block; margin-bottom: 6px;">Пароль</label>
|
||||
<input type="password" name="password" id="password" required
|
||||
style="width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px;">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn" style="width: 100%;">Войти</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -9,11 +9,17 @@ use App\Http\Controllers\RoomAvailabilityController;
|
||||
use App\Http\Controllers\BookingController;
|
||||
use App\Http\Controllers\InvoiceController;
|
||||
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/bookings/{id}/invoice', [InvoiceController::class, 'generate']);
|
||||
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::get('/hotels/{hotel}/room-types', function ($hotelId) {
|
||||
return \App\Models\RoomType::where('hotel_id', $hotelId)->get(['id', 'name']);
|
||||
});
|
||||
|
||||
Route::post('/admin/login', [AdminAuthController::class, 'login']);
|
||||
Route::post('/admin/logout', [AdminAuthController::class, 'logout'])->middleware('auth:sanctum');
|
||||
@@ -28,22 +34,10 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::get('/user', function (\Illuminate\Http\Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
||||
Route::get('/orders', [OrdersController::class, 'index']);
|
||||
Route::post('/orders', [OrdersController::class, 'create']);
|
||||
|
||||
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']);
|
||||
Route::put('/room-types/{id}', [RoomTypeController::class, 'update']);
|
||||
Route::delete('/room-types/{id}', [RoomTypeController::class, 'destroy']);
|
||||
@@ -54,6 +48,10 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/room-types/{id}/availability/bulk', [RoomAvailabilityController::class, 'bulkUpdate']);
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/bookings/{id}/invoice', [InvoiceController::class, 'generate']);
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('/bookings', [BookingController::class, 'store']);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\Admin\HotelController;
|
||||
use App\Http\Controllers\Admin\AuthController;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
// Вход
|
||||
Route::get('/admin/login', [\App\Http\Controllers\Admin\AuthController::class, 'showLoginForm'])->name('admin.login.form');
|
||||
Route::post('/admin/login', [\App\Http\Controllers\Admin\AuthController::class, 'login'])->name('admin.login');
|
||||
|
||||
// Админка (требует авторизации)
|
||||
Route::middleware('auth')->prefix('admin')->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::get('/hotels/{hotelId}/calendar', [\App\Http\Controllers\Admin\HotelController::class, 'calendar'])->name('admin.hotels.calendar');
|
||||
// Сохранение периода
|
||||
Route::post('/room-types/{roomType}/availability', [\App\Http\Controllers\Admin\AvailabilityController::class, 'store'])->name('admin.availability.store');
|
||||
// Удаление периода
|
||||
Route::delete('/availability/{availability}', [\App\Http\Controllers\Admin\AvailabilityController::class, 'destroy'])->name('admin.availability.destroy');
|
||||
// Бронирования
|
||||
Route::get('/bookings/create', [\App\Http\Controllers\Admin\BookingController::class, 'create'])->name('admin.bookings.create');
|
||||
Route::post('/bookings', [\App\Http\Controllers\Admin\BookingController::class, 'store'])->name('admin.bookings.store');
|
||||
|
||||
// Выход
|
||||
Route::post('/logout', [\App\Http\Controllers\Admin\AuthController::class, 'logout'])->name('admin.logout');
|
||||
});
|
||||
|
||||
// Вход
|
||||
Route::get('/admin/login', [\App\Http\Controllers\Admin\AuthController::class, 'showLoginForm'])->name('admin.login.form');
|
||||
Route::post('/admin/login', [\App\Http\Controllers\Admin\AuthController::class, 'login'])->name('admin.login');
|
||||
@@ -1,13 +0,0 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
laravel({
|
||||
input: ['resources/css/app.css', 'resources/js/app.js'],
|
||||
refresh: true,
|
||||
}),
|
||||
tailwindcss(),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user