31 lines
770 B
PHP
31 lines
770 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Room;
|
|
use App\Models\Booking;
|
|
use Carbon\Carbon;
|
|
|
|
class KamarController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$booking = Booking::where('id_user', auth()->id())
|
|
->orderBy('tanggal_booking', 'desc')
|
|
->first();
|
|
|
|
$rooms = Room::all();
|
|
|
|
$daysLeft = null;
|
|
|
|
if ($booking && $booking->status_booking === 'Dikonfirmasi' && $booking->tanggal_checkout) {
|
|
$today = Carbon::now();
|
|
$checkoutDate = Carbon::parse($booking->tanggal_checkout);
|
|
$daysLeft = $today->diffInDays($checkoutDate, false);
|
|
}
|
|
|
|
return view('users.peta', compact('booking', 'rooms', 'daysLeft'));
|
|
}
|
|
}
|