Hello to all, welcome to therichpost.com. In this post, I will tell you, laravel scheduler with delete query.
Your task schedule is defined in the app/Console/Kernel.php file’s schedule method. Laravel scheduler is the very feature of laravel which makes cron jobs easy to handle and code.
Here is example working query for laravel scheduler with delete query:
$schedule->call(function () { $now = \Carbon\Carbon::now(); DB::table('notifications') ->where('created_at', '<', $now->subDays(15))//I am deleting the 15 days old notifications ->delete(); })->daily(); }
If you want to start the scheduler itself then you will have to add one cron job on server using the crontab -e command:
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
If you have any query related to this post then please do comment.
Recent Comments