@php
$unavailableDates = [];
if(!empty(request('start')) && !empty(request('end')) && count(explode('/',request()->getPathInfo())) == 2){
$start = \Carbon\Carbon::createFromFormat('d/m/Y', request('start'))->toDateString();
$end = \Carbon\Carbon::createFromFormat('d/m/Y', request('end'))->toDateString();
$bookings = \Modules\Booking\Models\Booking::where('object_model', 'space')
->where('start_date', '>=', $start)
->where('end_date', '<=', $end)
->whereIn('status', ['draft', 'paid'])->where('object_id', $row->id)->get();
if(!$bookings->isEmpty()){
foreach($bookings as $booking)
{
$bookedDates = [];
$start_date = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $booking->start_date)->toDateString();
$end_date = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $booking->end_date)->toDateString();
$periods = \Carbon\CarbonPeriod::create($start_date, $end_date, \Carbon\CarbonPeriod::EXCLUDE_END_DATE);
foreach($periods as $period){
array_push($bookedDates, $period->toDateString());
}
// merge curent booked dates with the unavailable dates list
$unavailableDates = array_merge($unavailableDates, $bookedDates);
}
//remove the duplicate value
$unavailableDates = array_values(array_unique($unavailableDates));
}
}
@endphp
@if(!empty($row->location->name))
@php $location = $row->location->translate() @endphp
{{$location->name ?? ''}}
@endif
@if(count($unavailableDates) > 0)
@php
$data = json_encode($unavailableDates);
@endphp
Certain dates isn't available
@endif
{!! clean($translation->title) !!}
@if(setting_item('space_enable_review'))
@php
$reviewData = $row->getScoreReview();
$score_total = $reviewData['score_total'];
@endphp
@if($reviewData['total_review'] > 1)
{{ __(":number reviews",["number"=>$reviewData['total_review'] ]) }}
@else
{{ __(":number review",["number"=>$reviewData['total_review'] ]) }}
@endif
@endif
{{__("from")}}
{{ $row->display_sale_price }}
{{ $row->display_price }}