Accessing the database in laravel task scheduler code example
Example: Laravel Scheduler
$schedule->call(function () {
DB::table('users')->whereYear('last_login_at','<',date('Y')-1)->delete();
})->daily();
$schedule->call(function () {
DB::table('users')->whereYear('last_login_at','<',date('Y')-1)->delete();
})->daily();