//app/console/Kernel.php
use Illuminate\Support\Facades\Mail; //for use Mail facade
protected function schedule(Schedule $schedule)
{
$forgot = [];
$forgotCheckout = Working::whereNull('deleted_at')->get();
foreach($forgotCheckout as $forgot){
$forgot;
}
if(!is_null($forgot)){
$schedule->call(function () use($forgotCheckout){
Mail::send( //send email with valiable $forgot in View file.
'emails.forgot_checkout',
compact('forgotCheckout'),
function ($message) {
$message->to('test@email.com');
$message->subject('This is test mail');
}
);
})->daily()->when(function() use ($forgotCheckout){ //define how often do this job
if(!is_null($forgot)){
\Log::info(Daily check completed.); //write log file
return true; // when() will work when return is true.
}
else {
return false; // when() not work because return is false.
}
);
}
}
And you can make and modify to use your data with $forgot
data.
// view/emails/forgot_checkout.blade.php
This is test mail for scheduled mail sending...
@foreach($forgotCheckout as $forgot)
{{$forgot->id}}
{{$forgot->name}}
@endforeach
As most of you know, if you know how to do then it's not difficult:)