diff --git a/app/Http/Controllers/admin/BookingsController.php b/app/Http/Controllers/admin/BookingsController.php index 004904f..d8a4a52 100644 --- a/app/Http/Controllers/admin/BookingsController.php +++ b/app/Http/Controllers/admin/BookingsController.php @@ -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); } } \ No newline at end of file diff --git a/app/Http/Controllers/admin/TableController.php b/app/Http/Controllers/admin/TableController.php index f6bceba..d94723e 100644 --- a/app/Http/Controllers/admin/TableController.php +++ b/app/Http/Controllers/admin/TableController.php @@ -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, ]); diff --git a/app/Http/Controllers/pages/BookingHistoryController.php b/app/Http/Controllers/pages/BookingHistoryController.php index dcec0b8..63716e0 100644 --- a/app/Http/Controllers/pages/BookingHistoryController.php +++ b/app/Http/Controllers/pages/BookingHistoryController.php @@ -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')); diff --git a/resources/views/admin/bookings/index.blade.php b/resources/views/admin/bookings/index.blade.php index 62950e8..61ca856 100644 --- a/resources/views/admin/bookings/index.blade.php +++ b/resources/views/admin/bookings/index.blade.php @@ -33,7 +33,7 @@ class="form-input w-full rounded-md border-gray-300 focus:border-blue-500 focus: -
+ {{--
-
+
--}}
diff --git a/resources/views/admin/tables/create.blade.php b/resources/views/admin/tables/create.blade.php index 1d3c8ab..2c8a35f 100644 --- a/resources/views/admin/tables/create.blade.php +++ b/resources/views/admin/tables/create.blade.php @@ -49,19 +49,19 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
-
+ {{--
@error('status') -

{{ $message }}

+

{{ $message }}

@enderror -
+
--}}
Status @error('status') -

{{ $message }}

+

{{ $message }}

@enderror -
+ --}}
+ Riwayat Booking - - Pengaturan Akun - + + @if (Auth::user()->role === 'user') + + Pengaturan Akun + + @elseif (Auth::user()->role === 'admin') + + Halaman Admin + + @elseif (Auth::user()->role === 'superadmin') + + Halaman Superadmin + + @endif + @if (Auth::user()->email_verified_at === null) @@ -67,6 +82,7 @@ class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"> Verifikasi Email @endif +
@csrf
@@ -194,12 +206,12 @@ function showToast(message, type = 'info', duration = 5000) { toast.className = `${bgColor} text-white px-6 py-4 rounded-lg shadow-lg flex items-center space-x-3 min-w-80 transform transition-all duration-300 translate-x-full opacity-0`; toast.innerHTML = ` - - ${message} - - `; + + ${message} + + `; toastContainer.appendChild(toast); @@ -235,20 +247,20 @@ function showModal(title, message, type = 'info', callback = null) { }[type] || 'fa-info-circle'; modal.innerHTML = ` -
-
- -

${title}

-
-

${message}

-
- -
-
- `; +
+
+ +

${title}

+
+

${message}

+
+ +
+
+ `; document.body.appendChild(modal); @@ -267,22 +279,22 @@ function showConfirmModal(title, message, onConfirm, onCancel = null) { modal.className = 'fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4'; modal.innerHTML = ` -
-
- -

${title}

-
-

${message}

-
- - -
-
- `; +
+
+ +

${title}

+
+

${message}

+
+ + +
+
+ `; document.body.appendChild(modal); diff --git a/resources/views/superadmin/admin/index.blade.php b/resources/views/superadmin/admin/index.blade.php index ab944c3..4fd8dd8 100644 --- a/resources/views/superadmin/admin/index.blade.php +++ b/resources/views/superadmin/admin/index.blade.php @@ -1,186 +1,188 @@ @extends('layouts.super-admin') @section('content') -
-
-

Manajemen Admin

-

Kelola admin untuk setiap venue

+
+
+
+

Manajemen Admin

+

Kelola admin untuk setiap venue

+
+ + + Tambah Admin +
- - - Tambah Admin - -
- @if(session('success')) - - @endif + @if(session('success')) + + @endif - -
- -
-
- -
-
- + +
+ +
+
+ +
+
+ +
+
- +
+
+ + +
+
+ + + Reset Filter +
-
- - -
-
- - - Reset Filter - -
+ +
+ + +
+
+ + + + + + + + + + + + + @forelse($admins as $admin) + + + + + + + + + @empty + + + + @endforelse + +
+ Nama + + Email + + Venue + + Status + + Terdaftar + + Aksi +
+
+
+ +
+
+
{{ $admin->name }}
+
+
+
+
{{ $admin->email }}
+
+
+ @if($admin->venue) + {{ $admin->venue->name }} + @else + Tidak ada venue + @endif +
+
+ + {{ $admin->email_verified_at ? 'Terverifikasi' : 'Belum Verifikasi' }} + + + {{ $admin->created_at->format('d M Y') }} + + +
+ Tidak ada data admin ditemukan +
- -
- -
-
- - - - - - - - - - - - - @forelse($admins as $admin) - - - - - - - - - @empty - - - - @endforelse - -
- Nama - - Email - - Venue - - Status - - Terdaftar - - Aksi -
-
-
- -
-
-
{{ $admin->name }}
-
-
-
-
{{ $admin->email }}
-
-
- @if($admin->venue) - {{ $admin->venue->name }} - @else - Tidak ada venue - @endif -
-
- - {{ $admin->email_verified_at ? 'Terverifikasi' : 'Belum Verifikasi' }} - - - {{ $admin->created_at->format('d M Y') }} - - -
- Tidak ada data admin ditemukan -
+ +
+ {{ $admins->links() }} +
- -
- {{ $admins->links() }} -
-
- - - diff --git a/resources/views/superadmin/venue/index.blade.php b/resources/views/superadmin/venue/index.blade.php index 7fa2cc7..9135c55 100644 --- a/resources/views/superadmin/venue/index.blade.php +++ b/resources/views/superadmin/venue/index.blade.php @@ -1,219 +1,227 @@ @extends('layouts.super-admin') @section('content') -
-
-

Manajemen Venue

-

Kelola semua venue dalam sistem

+
+
+
+

Manajemen Venue

+

Kelola semua venue dalam sistem

+
+ + + Tambah Venue +
- - - Tambah Venue - -
- - @if(session('success')) - - @endif + + @if(session('success')) + + @endif - @if(session('error')) - - @endif + @if(session('error')) + + @endif - -
-
-
-
- -
-
- + +
+ +
+
+ +
+
+ +
+
- +
+
+ + +
+
+ + + Reset +
-
- - + +
+ + +
+ @forelse($venues as $venue) +
+
+ @php + // Tentukan path gambar yang akan ditampilkan + $imagePath = null; + + if ($venue->image) { + // Cek apakah file gambar ada di storage + if (Storage::disk('public')->exists($venue->image)) { + $imagePath = asset('storage/' . $venue->image); + } + // Cek apakah file gambar ada di public folder + elseif (file_exists(public_path($venue->image))) { + $imagePath = asset($venue->image); + } + // Cek jika path sudah lengkap dengan storage/ + elseif (file_exists(public_path('storage/' . $venue->image))) { + $imagePath = asset('storage/' . $venue->image); + } + } + + // Fallback ke placeholder jika gambar tidak ditemukan + if (!$imagePath) { + $imagePath = asset('images/venue-placeholder.jpg'); + } + @endphp + + {{ $venue->name }} + +
+ + + + +
+
+
+

{{ $venue->name }}

+
+ + {{ $venue->address }} +
+
+ + {{ $venue->phone }} +
+
+ + + {{ $venue->open_time ?? '00:00' }} - {{ $venue->close_time ?? '23:59' }} + +
+
+ + + {{ $venue->status == 'active' ? 'Aktif' : 'Tidak Aktif' }} + +
+ + @if($venue->description) +
+

{{ Str::limit($venue->description, 100) }}

+
+ @endif + +
+
+
+ {{ $venue->created_at->format('d M Y') }} +
+ + Detail + + +
+
+
-
- - - Reset - + @empty +
+
+ +

Belum ada venue

+

Mulai tambahkan venue baru untuk mengelola bisnis Anda dengan lebih baik +

+ + + Tambah Venue Pertama + +
+
+ @endforelse +
+ + + @if($venues->hasPages()) +
+
+ {{ $venues->appends(request()->query())->links() }}
- -
+ @endif - -
- @forelse($venues as $venue) -
-
- @php - // Tentukan path gambar yang akan ditampilkan - $imagePath = null; - - if ($venue->image) { - // Cek apakah file gambar ada di storage - if (Storage::disk('public')->exists($venue->image)) { - $imagePath = asset('storage/' . $venue->image); - } - // Cek apakah file gambar ada di public folder - elseif (file_exists(public_path($venue->image))) { - $imagePath = asset($venue->image); - } - // Cek jika path sudah lengkap dengan storage/ - elseif (file_exists(public_path('storage/' . $venue->image))) { - $imagePath = asset('storage/' . $venue->image); - } - } - - // Fallback ke placeholder jika gambar tidak ditemukan - if (!$imagePath) { - $imagePath = asset('images/venue-placeholder.jpg'); - } - @endphp - - {{ $venue->name }} - -
- - - -
-
-
-

{{ $venue->name }}

-
- - {{ $venue->address }} -
-
- - {{ $venue->phone }} -
-
- - - {{ $venue->open_time ?? '00:00' }} - {{ $venue->close_time ?? '23:59' }} - -
-
- - - {{ $venue->status == 'active' ? 'Aktif' : 'Tidak Aktif' }} - -
- - @if($venue->description) -
-

{{ Str::limit($venue->description, 100) }}

+
+
+
- @endif - -
-
-
- {{ $venue->created_at->format('d M Y') }} +

Hapus Venue

+

+ Apakah Anda yakin ingin menghapus venue ini? Semua data terkait dengan venue ini akan ikut + terhapus + dan tidak dapat dikembalikan. +

+
+ @csrf + @method('DELETE') +
+ +
- - Detail - - -
+
- @empty -
-
- -

Belum ada venue

-

Mulai tambahkan venue baru untuk mengelola bisnis Anda dengan lebih baik

- - - Tambah Venue Pertama - -
-
- @endforelse -
- - - @if($venues->hasPages()) -
-
- {{ $venues->appends(request()->query())->links() }} -
-
- @endif - - -