therock24
therock24

Reputation: 305

Error exception 'InvalidArgumentException' in Laravel

I have a strange problem with Laravel's schedule that I am trying to solve:

ERROR: exception 'InvalidArgumentException' with message 'Invalid scheduled callback event. Must be string or callable'.

This is the line of Kernel.php:

$schedule->call(\App\Classes\Maintenance::deleteAllRecord())->daily();

And this is the function :

public static function deleteAllRecord()
{
    $data=\App\LastSeen::all();
    foreach ($data as $dt)
    {
        $dt->delete();
    }
    return 'OK';
}

I try also return true , but I had the same problem.I'm sure that the problem is the type of return. Where I make the mistake ? I hope I was exhaustive. I wait answer ^_^ have a good day.

Upvotes: 3

Views: 2824

Answers (1)

salamas
salamas

Reputation: 515

You can call \App\Classes\Maintenance::deleteAllRecord() inside the callback. Like

$schedule->call(function(){
  \App\Classes\Maintenance::deleteAllRecord();
})->daily();

Upvotes: 7

Related Questions