Automate tasks with Laravel 5

5

Good morning, people.

I need to create some tasks on my system that run automatically (such as a Cron Job). Example: Every day the system sends an email to the customers of the system with the amount of their charges, and the ones that are close to winning.

I gave a read here in the Scheduler, but the documentation of laravel did not make it clear to me how this works. Could someone explain me better how this feature works? how do I create tasks according to my need?

    
asked by anonymous 09.03.2015 / 14:49

1 answer

6

Start by adding to cron an entry that runs the php artisan schedule:run command every minute.

So you can use it in several ways:

Commands:

$schedule->command('cache:clear')
    ->hourly()
    ->sendOutputTo($filePath)
    ->emailOutputTo('[email protected]'); 

Methods of a class:

$schedule->call('SomeClass@method')->dailyAt('10:00');

Anonymous role:

$schedule->call(function(){
    //.. 
})->everyThirtyMinutes();

Terminal Command:

$schedule->terminal('gulp task')->fridays()->when(function(){ 
    return true;
});

Source: link

    
09.03.2015 / 17:14