Checkpointt
This commit is contained in:
parent
cbbd272b15
commit
2d82a9489e
|
@ -15,7 +15,15 @@ class BookingsController extends Controller
|
|||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Booking::with(['table', 'user']);
|
||||
// Ambil venue_id dari admin yang sedang login
|
||||
// Sesuaikan dengan struktur database kamu:
|
||||
$adminVenueId = auth()->user()->venue_id; // Asumsi admin punya kolom venue_id
|
||||
|
||||
// Query booking dengan filter venue terlebih dahulu
|
||||
$query = Booking::with(['table', 'user'])
|
||||
->whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
});
|
||||
|
||||
// Search functionality
|
||||
if ($request->has('search') && !empty($request->search)) {
|
||||
|
@ -70,14 +78,30 @@ public function index(Request $request)
|
|||
|
||||
public function show($id)
|
||||
{
|
||||
$booking = Booking::with(['table', 'user'])->findOrFail($id);
|
||||
// Pastikan booking yang dilihat adalah milik venue admin
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
|
||||
$booking = Booking::with(['table', 'user'])
|
||||
->whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
})
|
||||
->findOrFail($id);
|
||||
|
||||
return view('admin.bookings.show', compact('booking'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$booking = Booking::findOrFail($id);
|
||||
$tables = Table::all();
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
|
||||
// Pastikan booking yang diedit adalah milik venue admin
|
||||
$booking = Booking::whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
})->findOrFail($id);
|
||||
|
||||
// Hanya tampilkan tables dari venue admin
|
||||
$tables = Table::where('venue_id', $adminVenueId)->get();
|
||||
|
||||
return view('admin.bookings.edit', compact('booking', 'tables'));
|
||||
}
|
||||
|
||||
|
@ -89,7 +113,18 @@ public function update(Request $request, $id)
|
|||
'end_time' => 'required|date|after:start_time',
|
||||
]);
|
||||
|
||||
$booking = Booking::findOrFail($id);
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
|
||||
// Pastikan booking yang diupdate adalah milik venue admin
|
||||
$booking = Booking::whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
})->findOrFail($id);
|
||||
|
||||
// Validasi tambahan: pastikan table_id yang dipilih juga milik venue admin
|
||||
$table = Table::where('id', $request->table_id)
|
||||
->where('venue_id', $adminVenueId)
|
||||
->firstOrFail();
|
||||
|
||||
$booking->update($request->all());
|
||||
|
||||
return redirect()->route('admin.bookings.index')
|
||||
|
@ -98,7 +133,12 @@ public function update(Request $request, $id)
|
|||
|
||||
public function complete($id)
|
||||
{
|
||||
$booking = Booking::findOrFail($id);
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
|
||||
$booking = Booking::whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
})->findOrFail($id);
|
||||
|
||||
$booking->status = 'selesai';
|
||||
$booking->save();
|
||||
|
||||
|
@ -108,7 +148,12 @@ public function complete($id)
|
|||
|
||||
public function cancel($id)
|
||||
{
|
||||
$booking = Booking::findOrFail($id);
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
|
||||
$booking = Booking::whereHas('table', function ($q) use ($adminVenueId) {
|
||||
$q->where('venue_id', $adminVenueId);
|
||||
})->findOrFail($id);
|
||||
|
||||
$booking->status = 'cancelled';
|
||||
$booking->save();
|
||||
|
||||
|
@ -118,7 +163,10 @@ public function cancel($id)
|
|||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$adminVenueId = auth()->user()->venue_id;
|
||||
$filename = 'bookings-' . Carbon::now()->format('Y-m-d') . '.xlsx';
|
||||
return Excel::download(new BookingsExport($request), $filename);
|
||||
|
||||
// Pass venue_id ke export class jika diperlukan
|
||||
return Excel::download(new BookingsExport($request, $adminVenueId), $filename);
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public function store(Request $request)
|
|||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'brand' => 'required|string|max:255',
|
||||
'status' => 'required|in:Available,Booked,Unavailable',
|
||||
// 'status' => 'required|in:Available,Booked,Unavailable',
|
||||
'price_per_hour' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
|
@ -68,7 +68,7 @@ public function store(Request $request)
|
|||
Table::create([
|
||||
'name' => $request->name,
|
||||
'brand' => $request->brand,
|
||||
'status' => $request->status,
|
||||
// 'status' => $request->status,
|
||||
'price_per_hour' => $request->price_per_hour,
|
||||
'venue_id' => auth()->user()->venue_id,
|
||||
]);
|
||||
|
@ -101,7 +101,7 @@ public function update(Request $request, $id)
|
|||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'brand' => 'required|string|max:255',
|
||||
'status' => 'required|in:Available,Booked,Unavailable',
|
||||
// 'status' => 'required|in:Available,Booked,Unavailable',
|
||||
'price_per_hour' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
|
@ -116,7 +116,7 @@ public function update(Request $request, $id)
|
|||
$table->update([
|
||||
'name' => $request->name,
|
||||
'brand' => $request->brand,
|
||||
'status' => $request->status,
|
||||
// 'status' => $request->status,
|
||||
'price_per_hour' => $request->price_per_hour,
|
||||
]);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ public function index()
|
|||
{
|
||||
$bookings = Booking::where('user_id', Auth::id())
|
||||
->with(['table.venue'])
|
||||
->orderBy('start_time', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
return view('pages.booking-history', compact('bookings'));
|
||||
|
|
|
@ -33,7 +33,7 @@ class="form-input w-full rounded-md border-gray-300 focus:border-blue-500 focus:
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full md:w-1/4">
|
||||
{{-- <div class="w-full md:w-1/4">
|
||||
<label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
||||
<select name="status" id="status"
|
||||
class="form-select w-full rounded-md border-gray-300 focus:border-blue-500 focus:ring focus:ring-blue-200">
|
||||
|
@ -43,7 +43,7 @@ class="form-select w-full rounded-md border-gray-300 focus:border-blue-500 focus
|
|||
<option value="cancelled" {{ request('status') == 'cancelled' ? 'selected' : '' }}>Dibatalkan
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="w-full md:w-1/4">
|
||||
<label for="date_from" class="block text-sm font-medium text-gray-700 mb-1">Dari Tanggal</label>
|
||||
|
|
|
@ -49,19 +49,19 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{-- <div>
|
||||
<label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
||||
<select id="status" name="status"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 @error('status') border-red-500 @enderror">
|
||||
<option value="Available" {{ old('status') === 'Available' ? 'selected' : '' }}>Available</option>
|
||||
<option value="Booked" {{ old('status') === 'Booked' ? 'selected' : '' }}>Booked</option>
|
||||
<option value="Unavailable" {{ old('status') === 'Unavailable' ? 'selected' : '' }}>Unavailable
|
||||
<option value="Available" {{ old('status')==='Available' ? 'selected' : '' }}>Available</option>
|
||||
<option value="Booked" {{ old('status')==='Booked' ? 'selected' : '' }}>Booked</option>
|
||||
<option value="Unavailable" {{ old('status')==='Unavailable' ? 'selected' : '' }}>Unavailable
|
||||
</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="flex justify-end space-x-3">
|
||||
<a href="{{ route('admin.tables.index') }}"
|
||||
|
|
|
@ -50,7 +50,7 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{-- <div>
|
||||
<label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
||||
<select id="status" name="status"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 @error('status') border-red-500 @enderror">
|
||||
|
@ -58,12 +58,13 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
|
|||
Available</option>
|
||||
<option value="Booked" {{ old('status', $table->status) === 'Booked' ? 'selected' : '' }}>Booked
|
||||
</option>
|
||||
<option value="Unavailable" {{ old('status', $table->status) === 'Unavailable' ? 'selected' : '' }}>Unavailable</option>
|
||||
<option value="Unavailable" {{ old('status', $table->status) === 'Unavailable' ? 'selected' : ''
|
||||
}}>Unavailable</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="flex justify-end space-x-3">
|
||||
<a href="{{ route('admin.tables.index') }}"
|
||||
|
|
|
@ -52,14 +52,29 @@ class="flex items-center space-x-2 text-sm font-medium text-gray-700 hover:text-
|
|||
|
||||
<div x-show="open" @click.away="open = false" x-transition
|
||||
class="absolute right-0 mt-2 w-40 bg-white rounded-lg shadow-lg py-2 z-50">
|
||||
|
||||
<a href="{{ route('booking.history') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
||||
Riwayat Booking
|
||||
</a>
|
||||
|
||||
@if (Auth::user()->role === 'user')
|
||||
<a href="{{ route('account.settings') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
||||
Pengaturan Akun
|
||||
</a>
|
||||
@elseif (Auth::user()->role === 'admin')
|
||||
<a href="{{ url('/admin') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
||||
Halaman Admin
|
||||
</a>
|
||||
@elseif (Auth::user()->role === 'superadmin')
|
||||
<a href="{{ url('/superadmin') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
||||
Halaman Superadmin
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->email_verified_at === null)
|
||||
<a href="{{ route('verification.notice') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
||||
|
@ -67,6 +82,7 @@ class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
|
|||
Verifikasi Email
|
||||
</a>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<button type="submit"
|
||||
|
|
|
@ -21,7 +21,7 @@ class="fixed inset-0 bg-black bg-opacity-50 z-40 flex items-center justify-cente
|
|||
class="w-full h-full object-cover rounded-lg mb-4 mt-8" />
|
||||
|
||||
<h1 class="text-xl text-gray-800 font-semibold">{{ $venue['name'] }}</h1>
|
||||
<p class="text-sm text-gray-500">{{ $venue['location'] ?? 'Lokasi tidak tersedia' }}</p>
|
||||
<p class="text-sm text-gray-500">{{ $venue['description'] ?? 'Tidak ada deskripsi.' }}</p>
|
||||
@if($venue['status'] === 'open')
|
||||
{{-- Venue sedang buka - tampilkan jam operasional --}}
|
||||
<p class="text-sm text-gray-600 mt-1">
|
||||
|
@ -147,15 +147,27 @@ class="border rounded-lg shadow-md p-4 mb-4">
|
|||
</select>
|
||||
|
||||
<h4 class="font-semibold mb-2 mt-4">Pilih Durasi Main:</h4>
|
||||
@if ($venue['status'] === 'open')
|
||||
<select class="w-full border p-2 rounded-lg" x-model="selectedDuration">
|
||||
<option value="">-- Pilih Durasi --</option>
|
||||
<option value="1">1 Jam</option>
|
||||
<option value="2">2 Jam</option>
|
||||
<option value="3">3 Jam</option>
|
||||
{{-- <option value="4">4 Jam</option>
|
||||
<option value="5">5 Jam</option> --}}
|
||||
</select>
|
||||
@else
|
||||
<select class="w-full border p-2 rounded-lg bg-gray-100 text-gray-400 cursor-not-allowed" disabled>
|
||||
<option value="">Venue sedang tutup</option>
|
||||
</select>
|
||||
@endif
|
||||
|
||||
<button class="mt-3 px-4 py-2 bg-green-500 text-white rounded-lg w-full" :disabled="!selectedTime || !selectedDuration || isLoading"
|
||||
<button
|
||||
class="mt-3 px-4 py-2 rounded-lg w-full
|
||||
{{ $venue['status'] === 'open' ? 'bg-green-500 text-white' : 'bg-gray-400 text-gray-700 cursor-not-allowed' }}"
|
||||
:disabled="!selectedTime || !selectedDuration || isLoading || '{{ $venue['status'] }}' !== 'open'"
|
||||
@click="initiateBooking('{{ $table['id'] }}', '{{ addslashes($table['name']) }}')">
|
||||
|
||||
<template x-if="isLoading">
|
||||
<span>Loading...</span>
|
||||
</template>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@extends('layouts.super-admin')
|
||||
|
||||
@section('content')
|
||||
<div class="p-6">
|
||||
<div class="mb-6 flex justify-between items-center">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-800">Manajemen Admin</h1>
|
||||
|
@ -185,6 +186,7 @@ class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@extends('layouts.super-admin')
|
||||
|
||||
@section('content')
|
||||
<div class="p-6">
|
||||
<div class="mb-6 flex justify-between items-center">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-800">Manajemen Venue</h1>
|
||||
|
@ -47,11 +48,13 @@ class="pl-10 block w-full rounded-md border-gray-300 shadow-sm focus:border-gree
|
|||
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-green-500 focus:ring-green-500">
|
||||
<option value="">Semua Status</option>
|
||||
<option value="active" {{ request('status') == 'active' ? 'selected' : '' }}>Aktif</option>
|
||||
<option value="inactive" {{ request('status') == 'inactive' ? 'selected' : '' }}>Tidak Aktif</option>
|
||||
<option value="inactive" {{ request('status') == 'inactive' ? 'selected' : '' }}>Tidak Aktif
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="self-end">
|
||||
<button type="submit" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 text-sm">
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 text-sm">
|
||||
Filter
|
||||
</button>
|
||||
<a href="{{ route('superadmin.venue.index') }}"
|
||||
|
@ -124,8 +127,10 @@ class="p-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors d
|
|||
</span>
|
||||
</div>
|
||||
<div class="flex items-center mb-4">
|
||||
<i class="fas fa-circle {{ $venue->status == 'active' ? 'text-green-500' : 'text-red-500' }} mr-2"></i>
|
||||
<span class="text-sm font-medium {{ $venue->status == 'active' ? 'text-green-700' : 'text-red-700' }}">
|
||||
<i
|
||||
class="fas fa-circle {{ $venue->status == 'active' ? 'text-green-500' : 'text-red-500' }} mr-2"></i>
|
||||
<span
|
||||
class="text-sm font-medium {{ $venue->status == 'active' ? 'text-green-700' : 'text-red-700' }}">
|
||||
{{ $venue->status == 'active' ? 'Aktif' : 'Tidak Aktif' }}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -155,7 +160,8 @@ class="text-green-600 hover:text-green-800 flex items-center text-sm transition-
|
|||
<div class="max-w-sm mx-auto">
|
||||
<i class="fas fa-building text-gray-300 text-6xl mb-4"></i>
|
||||
<h3 class="text-xl font-semibold text-gray-900 mb-2">Belum ada venue</h3>
|
||||
<p class="text-gray-500 mb-6">Mulai tambahkan venue baru untuk mengelola bisnis Anda dengan lebih baik</p>
|
||||
<p class="text-gray-500 mb-6">Mulai tambahkan venue baru untuk mengelola bisnis Anda dengan lebih baik
|
||||
</p>
|
||||
<a href="{{ route('superadmin.venue.create') }}"
|
||||
class="px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 inline-flex items-center transition-colors duration-200">
|
||||
<i class="fas fa-plus mr-2"></i>
|
||||
|
@ -195,7 +201,8 @@ class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounde
|
|||
</div>
|
||||
<h3 class="mb-2 text-lg font-semibold text-gray-900">Hapus Venue</h3>
|
||||
<p class="mb-6 text-sm text-gray-500">
|
||||
Apakah Anda yakin ingin menghapus venue ini? Semua data terkait dengan venue ini akan ikut terhapus
|
||||
Apakah Anda yakin ingin menghapus venue ini? Semua data terkait dengan venue ini akan ikut
|
||||
terhapus
|
||||
dan tidak dapat dikembalikan.
|
||||
</p>
|
||||
<form id="deleteVenueForm" method="POST" action="" class="space-y-4">
|
||||
|
@ -216,6 +223,7 @@ class="px-4 py-2 bg-white text-gray-700 text-sm font-medium rounded-lg border bo
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function confirmDelete(venueId) {
|
||||
|
|
Loading…
Reference in New Issue