It seems like the job is not being dispatched properly. One possible solution is to manually dispatch the job in the test route and see if it works. If it does, then the issue might be with the scheduling.
Another possible solution is to check if the queue driver is set to "database" in the .env file. If it is not, then change it to "database" and run the migration command to create the necessary tables for the queue.
Also, make sure that the job is properly serialized and unserialized. One way to do this is to implement the ShouldQueue interface in the job class.
Here's an updated version of the DispatchUsefulInfoEmail job class that implements the ShouldQueue interface:
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class DispatchUsefulInfoEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle()
{
// Retrieve rentals that start within the next 5 days
$rentals = Rental::where('pick_up_date', '<=', now()->addDays(5)->format('d/m/Y'))
->where('status', BookingStatusEnum::CREATED)
->get();
$rentals->each(function ($rental) {
// Send notification
Notification::route('mail', $rental->customer->email_address)->notify(new UsefulInfoNotification($rental));
});
}
}
Note that the ShouldQueue interface is added and the job class now uses the Queueable, InteractsWithQueue, and SerializesModels traits.