diff --git a/app/Http/Controllers/admin/VenueController.php b/app/Http/Controllers/admin/VenueController.php new file mode 100644 index 0000000..c56cf88 --- /dev/null +++ b/app/Http/Controllers/admin/VenueController.php @@ -0,0 +1,114 @@ +user()->venue; + + if (!$venue) { + return redirect()->route('admin.dashboard')->with('error', 'Anda belum memiliki venue yang ditugaskan.'); + } + + return view('admin.venues.index', compact('venue')); + } + + /** + * Show the form for editing venue + */ + public function edit() + { + $venue = auth()->user()->venue; + + if (!$venue) { + return redirect()->route('admin.dashboard')->with('error', 'Anda belum memiliki venue yang ditugaskan.'); + } + + return view('admin.venues.edit', compact('venue')); + } + + /** + * Update venue information + */ + public function update(Request $request) + { + $venue = auth()->user()->venue; + + if (!$venue) { + return redirect()->route('admin.dashboard')->with('error', 'Anda belum memiliki venue yang ditugaskan.'); + } + + // Validation rules + $validator = Validator::make($request->all(), [ + 'name' => 'required|string|max:255', + 'address' => 'required|string|max:500', + 'phone' => 'nullable|string|max:20', + 'description' => 'nullable|string|max:1000', + 'open_time' => 'required|date_format:H:i', + 'close_time' => 'required|date_format:H:i', + 'image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048', // Max 2MB + ], [ + 'name.required' => 'Nama venue harus diisi.', + 'address.required' => 'Alamat venue harus diisi.', + 'open_time.required' => 'Jam buka harus diisi.', + 'open_time.date_format' => 'Format jam buka tidak valid (gunakan format HH:MM).', + 'close_time.required' => 'Jam tutup harus diisi.', + 'close_time.date_format' => 'Format jam tutup tidak valid (gunakan format HH:MM).', + 'image.image' => 'File yang diupload harus berupa gambar.', + 'image.mimes' => 'Gambar harus berformat: jpeg, png, jpg, atau gif.', + 'image.max' => 'Ukuran gambar maksimal 2MB.', + ]); + + if ($validator->fails()) { + return redirect()->back() + ->withErrors($validator) + ->withInput(); + } + + try { + // Handle image upload + $imagePath = $venue->image; // Keep current image by default + + if ($request->hasFile('image')) { + // Delete old image if exists + if ($venue->image && Storage::disk('public')->exists($venue->image)) { + Storage::disk('public')->delete($venue->image); + } + + // Store new image + $imagePath = $request->file('image')->store('venues', 'public'); + } + + // Update venue data + $venue->update([ + 'name' => $request->name, + 'address' => $request->address, + 'phone' => $request->phone, + 'description' => $request->description, + 'open_time' => $request->open_time, + 'close_time' => $request->close_time, + 'image' => $imagePath, + ]); + + return redirect()->route('admin.venue.index') + ->with('success', 'Informasi venue berhasil diperbarui!'); + + } catch (\Exception $e) { + return redirect()->back() + ->with('error', 'Terjadi kesalahan saat memperbarui venue: ' . $e->getMessage()) + ->withInput(); + } + } +} \ No newline at end of file diff --git a/app/Models/Venue.php b/app/Models/Venue.php index 22cf6b9..a57d6b7 100644 --- a/app/Models/Venue.php +++ b/app/Models/Venue.php @@ -9,7 +9,20 @@ class Venue extends Model { use HasFactory; - protected $fillable = ['name', 'location', 'address', 'image']; + protected $fillable = [ + 'name', + 'address', + 'image', + 'phone', // Pastikan field ini ada + 'description', // Pastikan field ini ada + 'open_time', // Pastikan field ini ada + 'close_time', // Pastikan field ini ada + ]; + + protected $casts = [ + 'open_time' => 'datetime', + 'close_time' => 'datetime', + ]; public function tables() { diff --git a/resources/views/admin/venues/edit.blade.php b/resources/views/admin/venues/edit.blade.php new file mode 100644 index 0000000..da8f180 --- /dev/null +++ b/resources/views/admin/venues/edit.blade.php @@ -0,0 +1,206 @@ +@extends('layouts.admin') + +@section('content') +
Perbarui informasi venue Anda
+Kelola informasi venue Anda
+{{ $venue->description ?: 'Belum ada deskripsi' }}
+Total Meja
+{{ $venue->tables->count() }}
+Meja Tersedia
++ {{ $venue->tables->where('status', 'available')->count() }}
+Meja Terpakai
++ {{ $venue->tables->where('status', 'occupied')->count() }}
+{{ $venue['location'] ?? 'Lokasi tidak tersedia' }}
Jam Operasional: {{ date('H:i', strtotime($venue['open_time'])) }} - @@ -182,12 +183,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); @@ -223,20 +224,20 @@ function showModal(title, message, type = 'info', callback = null) { }[type] || 'fa-info-circle'; modal.innerHTML = ` -
${message}
+${message}
-${message}
+${message}
-