I found the following error in my laravel.log,
[2023-05-15 22:52:36] local.ERROR: Undefined variable $newBinds (SQL: select * from [asset_timeslot] where exists (select * from [timeslots] where [asset_timeslot].[timeslot_id] = [timeslots].[id]) and [asset_id] = 2) {"userId":1,"exception":"[object] (Illuminate\Database\QueryException(code: 0): Undefined variable $newBinds (SQL: select * from [asset_timeslot] where exists (select * from [timeslots] where [asset_timeslot].[timeslot_id] = [timeslots].[id]) and [asset_id] = 2) at /home/jabs/workspace/ipbt/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)
I tried to look for file other than /vendor/ and it refer to the following file code,
public function __invoke(Asset $asset, Activity $activity, Carbon $from, Carbon $to)
{
$timeslots = AssetTimeslot::query()
->with([
'bookings' => fn ($query) => $query
->with('activity', 'timeslots')
->where('asset_id', $asset->id)
->where('start_date', '>=', $from)
->where('end_date', '<=', $to)
->where('status', '!=', BookingStatus::CANCELLED->value),
'timeslot.activity',
])
->whereHas('timeslot')
->where('asset_id', $asset->id)
->get();
$period = CarbonPeriod::create($from, $to);
public static function run(...$params): mixed
{
$action = static::make();
$method = method_exists($action, 'handle') ? 'handle' : '__invoke';
return $action->{$method}(...$params);
}
public function create(Request $request)
{
$availableTimeslots = [];
if ($request->filled('asset_id')) {
$asset = Asset::with(['activities', 'timeslots'])->find($request->query('asset_id'));
$dateFrom = $request->date('from') ?? today();
$dateTo = $request->date('to') ?? today();
$activity = $asset->activities()->findOrFail($request->query('activity'));
$availableTimeslots = GetAssetTimeslotByDate::run($asset, $activity, $dateFrom, $dateTo);
// $availableTimeslots=format('%d %B %Y');
}
dd('debug timeslot');
return Inertia::render('Booking/Create', [
'assets' => $request->filled('activity') ?
GetAssets::run($request->query(), [
'with' => [
'category',
'section',
'group',
'activities',
'facilities',
'additionalFacilities',
'supervisors',
'timeslots',
],
'active' => true,
'paginate' => false,
])
: [],
'availableTimeslots' => $availableTimeslots,
'bookings' => $request->filled('user_id') ?
GetBookings::run($request->query(), [
'user' => $request->user(),
])->first()
: null,
'filters' => fn () => [
'activityType' => $request->query('activityType', ''),
'activity' => $request->query('activity', ''),
'userId' => $request->query('user_id', ''),
],
]);
I tried to dd() in public function create() and it shows on the screen. However if I put it at the most bottom, I just get a white blank screen.
I've no idea how can I fix this ? Please help