Fitur batasan reschedule
This commit is contained in:
parent
c39bbc6bae
commit
ac9d47071e
|
|
@ -494,6 +494,11 @@ public function showReschedule($id)
|
|||
if ($booking->start_time <= now() || $booking->status !== 'paid') {
|
||||
return redirect()->route('booking.history')->with('error', 'Booking ini tidak dapat di-reschedule.');
|
||||
}
|
||||
|
||||
// Check if booking has reached reschedule limit
|
||||
if ($booking->reschedule_count >= 1) {
|
||||
return redirect()->route('booking.history')->with('error', 'Booking ini sudah pernah di-reschedule sebelumnya dan tidak dapat di-reschedule lagi.');
|
||||
}
|
||||
|
||||
// Check if it's within the time limit (at least 1 hour before start)
|
||||
$rescheduleDeadline = Carbon::parse($booking->start_time)->subHour();
|
||||
|
|
@ -557,6 +562,9 @@ public function processReschedule(Request $request, $id)
|
|||
$booking->end_time = $request->end_time;
|
||||
$booking->table_id = $request->table_id;
|
||||
$booking->save();
|
||||
|
||||
// Increment reschedule count
|
||||
$booking->increment('reschedule_count');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddRescheduleColumnsToBookingsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->boolean('has_rescheduled')->default(false);
|
||||
$table->timestamp('original_start_time')->nullable();
|
||||
$table->timestamp('original_end_time')->nullable();
|
||||
$table->unsignedBigInteger('original_table_id')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->dropColumn(['has_rescheduled', 'original_start_time', 'original_end_time', 'original_table_id']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->integer('reschedule_count')->default(0)->after('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->dropColumn('reschedule_count');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -69,12 +69,10 @@ class="px-3 py-1 rounded-full text-sm {{ $booking->start_time > now() ? 'bg-gree
|
|||
<a href="{{ route('venue', $booking->table->venue->name) }}"
|
||||
class="text-blue-500 hover:underline">Lihat Venue</a>
|
||||
|
||||
@if(!$booking->has_rescheduled && \Carbon\Carbon::parse($booking->start_time)->subHour() > now())
|
||||
<a href="{{ route('booking.reschedule.form', $booking->id) }}"
|
||||
class="text-orange-500 hover:underline">
|
||||
Reschedule
|
||||
</a>
|
||||
@endif
|
||||
<a href="{{ route('booking.reschedule.form', $booking->id) }}"
|
||||
class="text-orange-500 hover:underline">
|
||||
Reschedule
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
<h3 class="font-semibold text-yellow-700">Perhatian</h3>
|
||||
<p class="text-yellow-700 text-sm">
|
||||
• Reschedule dapat dilakukan selama minimal 1 jam sebelum jadwal booking<br>
|
||||
• Setiap booking hanya dapat di-reschedule maksimal 1 kali<br>
|
||||
• Durasi booking akan tetap sama ({{ $duration }} jam)<br>
|
||||
• Setelah reschedule, jadwal lama akan digantikan dengan jadwal baru
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue