JohnSmith :
How I can create automatically record daily with laravel task scheduling without running artisan command. In my case I just want when the date is 28-02-2020 create record in db, when date is 29-02-2020 create another record and etc...
Hafez Divandari :
Just check Laravel docs on Task Scheduling. First add this cron entry:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Then, You may define all of your scheduled tasks in the schedule
method of the App\Console\Kernel
class:
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('your_table')->insert([
'first_column' => 'first_value',
// List other columns
]);
})->daily();
}