php - Laravel schedule job with method when()
Get the solution ↓↓↓Solution:
Try the following code.
protected function schedule(Schedule $schedule)
{
$forgot = [];
$schedule->call(function () {
$forgotCheckout = Working::whereNull('deleted_at')->get();
foreach($forgotCheckout as $forgot){
$forgot;
}
Mail::send(
'emails.forgot_checkout',
compact('forgot'),
function ($message) use ($forgot) {
$message->to('[email protected]');
$message->subject('This is test mail');
}
);
})->daily()->when(function() use($forgot) {
if(is_null($forgot)){
return false;
}
else{
return true;
}
});
}
Changed line of code:
->daily()->when(function() use($forgot) {
Answer
Solution:
If you have a look at the , the method
when
runs theCallable
object without passing any argument.
Instead your code requires an argument:
})->everyMinute()->when(function ($forgot){
So you have to change your code in order to use the$forgot
variable (initializing it in your method) and change your code like this:
})->everyMinute()->when(function () use($forgot){
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the process class relies on proc_open, which is not available on your php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.