I know it's been a while since the original question was asked, but I spent more time than I probably should have figuring this out myself... so I thought I'd share.
Task scheduling really is the way to go here, but you might have trouble when you play things out on production – because Laravel throws a confirmation warning when you run db:seed
in production environments:
That throws a wrench in things when you try to run it via the scheduler.
The trick is to use --force
, but obviously, make sure you really want to do this on production — the confirmation's there for a reason, after all:
use Illuminate\Support\Facades\Schedule;
Schedule::command('db:seed ApiPlayerStatisticsSeeder --force')
->daily();
(And by the way, logging the output can be really helpful when you're debugging.)