Modif Fungsi create edit delete meja di admin

This commit is contained in:
Stephen Gesityan 2025-05-13 00:19:34 +07:00
parent f3020d2089
commit 1ccfbfa336
6 changed files with 66 additions and 32 deletions

View File

@ -56,6 +56,7 @@ public function store(Request $request)
'name' => 'required|string|max:255',
'brand' => 'required|string|max:255',
'status' => 'required|in:Available,Booked,Unavailable',
'price_per_hour' => 'required|numeric|min:0',
]);
if ($validator->fails()) {
@ -68,6 +69,7 @@ public function store(Request $request)
'name' => $request->name,
'brand' => $request->brand,
'status' => $request->status,
'price_per_hour' => $request->price_per_hour,
'venue_id' => auth()->user()->venue_id,
]);
@ -100,6 +102,7 @@ public function update(Request $request, $id)
'name' => 'required|string|max:255',
'brand' => 'required|string|max:255',
'status' => 'required|in:Available,Booked,Unavailable',
'price_per_hour' => 'required|numeric|min:0',
]);
if ($validator->fails()) {
@ -114,6 +117,7 @@ public function update(Request $request, $id)
'name' => $request->name,
'brand' => $request->brand,
'status' => $request->status,
'price_per_hour' => $request->price_per_hour,
]);
return redirect()->route('admin.tables.index')
@ -129,6 +133,9 @@ public function update(Request $request, $id)
public function destroy($id)
{
$table = Table::where('venue_id', auth()->user()->venue_id)->findOrFail($id);
$table->bookings()->delete();
$table->delete();
return redirect()->route('admin.tables.index')

View File

@ -13,8 +13,26 @@ class HomeController extends Controller
// $this->middleware('auth');
// }
public function index() {
$venues = Venue::paginate(10);
public function index(Request $request) {
// Start with base query
$query = Venue::query();
// Search by venue name
if ($request->filled('name')) {
$query->where('name', 'like', '%' . $request->input('name') . '%');
}
// Filter by city/location (assuming this is based on address)
if ($request->filled('location')) {
$query->where('address', 'like', '%' . $request->input('location') . '%');
}
// Paginate the results
$venues = $query->paginate(6);
// Retain the search parameters for pagination links
$venues->appends($request->only(['name', 'location']));
return view('pages.home', compact('venues'));
}
}

View File

@ -37,6 +37,16 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div>
<label for="price_per_hour" class="block text-sm font-medium text-gray-700 mb-1">Price Per
Hour</label>
<input type="number" id="price_per_hour" name="price_per_hour"
value="{{ old('price_per_hour') }}" placeholder="ex: 50000"
class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 @error('price_per_hour') border-red-500 @enderror">
@error('price_per_hour')
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
</div>
<div>

View File

@ -36,6 +36,18 @@ class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none foc
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div>
<label for="price_per_hour" class="block text-sm font-medium text-gray-700 mb-1">Price Per
Hour</label>
<input type="number" id="price_per_hour" name="price_per_hour"
value="{{ old('price_per_hour', $table->price_per_hour) }}"
placeholder="Masukkan merek meja"
class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 @error('price_per_hour') border-red-500 @enderror">
@error('price_per_hour')
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
</div>
<div>

View File

@ -13,66 +13,49 @@
</div>
</div>
<div class="flex flex-col md:flex-row lg:justify-center">
<form action="{{ route('home') }}" method="GET" class="flex flex-col md:flex-row lg:justify-center">
<div class="mx-4 lg:mx-0 mb-5 flex items-center border border-gray-300 md:border-0 rounded-lg">
<span class="text-gray-500 px-3">
<i class="fas fa-search"></i>
</span>
<input type="text"
<input type="text" name="name"
class="border w-full border-gray-300 py-3 px-4 rounded-e-lg focus:outline-none focus:ring focus:ring-blue-200 text-sm text-gray-500"
placeholder="Cari nama venue">
placeholder="Cari nama venue" value="{{ request('name') }}">
</div>
<div class="mx-4 lg:mx-0 mb-5 flex items-center border border-gray-300 md:border-0 rounded-lg">
<span class="text-gray-500 px-3">
<i class="fas fa-location"></i>
</span>
<input type="text"
<input type="text" name="location"
class="border w-full border-gray-300 py-3 px-4 rounded-e-lg focus:outline-none focus:ring focus:ring-blue-200 text-sm text-gray-500"
placeholder="Pilih Kota">
</div>
<div class="mx-4 lg:mx-0 mb-5 flex items-center border border-gray-300 md:border-0 rounded-lg">
<span class="text-gray-500 px-3">
<i class="fa-solid fa-key"></i>
</span>
<input type="text"
class="border w-full border-gray-300 py-3 px-4 rounded-e-lg focus:outline-none focus:ring focus:ring-blue-200 text-sm text-gray-500"
placeholder="Billiard">
</div>
<div class="px-4 lg:ps-4 md:px-0 mb-5">
<button class="w-full py-3 md:px-4 rounded-lg bg-[#F2E3E5]">
<i class="fa-solid fa-filter"></i>
</button>
placeholder="Pilih Kota" value="{{ request('location') }}">
</div>
<div class="px-4">
<button
<button type="submit"
class="w-full py-3 md:px-6 rounded-lg text-sm bg-primary text-white font-semibold md:whitespace-nowrap">
<h6>Cari venue</h6>
</button>
</div>
</div>
</form>
<hr class="my-4 md:mx-4 lg:mx-44 bg-gray-500 hidden md:block">
<div class="md:flex md:justify-between md:mb-14">
<div class="px-4 lg:px-44 mt-6 md:mt-0 md:flex md:flex-row">
<h6 class="text-gray-400 text-sm">Menampilkan: </h6>
<p class="text-gray-400 text-sm">6</p>
<p class="text-gray-400 text-sm">venue tersedia</p>
<p class="text-gray-400 text-sm ml-1">{{ $venues->total() }}</p>
<p class="text-gray-400 text-sm ml-1">venue tersedia</p>
<hr class="my-4 md:my-0 bg-gray-500">
</div>
<div class="px-4 lg:px-44">
<p class="text-sm text-gray-400 mb-10 md:mb-0">Urutkan berdasarkan: <span class="text-gray-700">Harga
terendah</span></p>
</div>
</div>
<div class="px-4 lg:px-44">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
@forelse ($venues as $venue)
<a href="/venue/{{ ($venue->name) }}"
<a href="{{ route('venue', ['venueName' => $venue->name]) }}"
class="flex flex-col h-full border border-gray-400 rounded-lg overflow-hidden">
<img src="{{ $venue->image }}" alt="{{ $venue->name }}" class="w-full h-48 object-cover">
<div class="flex-grow px-4 py-2">
<h3 class="text-sm text-gray-400 font-semibold mb-2">Venue</h3>
<h1 class="text-xl text-gray-800 font-semibold">{{ $venue->name }}</h1>
<p class="text-sm text-gray-500">Genteng</p>
<p class="text-sm text-gray-500">{{ $venue->address }}</p>
<p class="mt-10 text-gray-500 text-sm">Mulai:
<span class="font-bold text-gray-800">Rp30,000</span>
<span class="text-gray-400 font-thin text-sm">/ jam</span>
@ -83,7 +66,11 @@ class="flex flex-col h-full border border-gray-400 rounded-lg overflow-hidden">
<p class="text-center col-span-full text-gray-500">Belum ada venue tersedia.</p>
@endforelse
</div>
</div>
{{-- Pagination Links --}}
<div class="mt-4">
{{ $venues->links() }}
</div>
</div>
</div>
@endsection

View File

@ -21,7 +21,7 @@
// Rute custom untuk verifikasi email
Route::get('/email/verified', [VerificationController::class, 'verified'])->name('verification.verified');
Route::get('/', [HomeController::class, "index"])->name('index');
Route::get('/', [HomeController::class, "index"])->name('home');
Route::get('/venue/{venueName}', [VenueController::class, "venue"])->name('venue');
// Changed routes for the new booking flow