Home > OS >  Is there a way to automatically assign the data by the schedule date or time in laravel, flutter or
Is there a way to automatically assign the data by the schedule date or time in laravel, flutter or

Time:10-30

Let say I want to post a new data through api. For eg, I am assigning "Milo" as a name on October 10.

{
  "name": "Milo",
  "time": 3
}

Then 3 days later, on October 13, I want "Cola" to be the name automatically, not "Milo". I don't want to assign it manually. I want to automate it.

Is there a way to do it in laravel, flutter or dart?

CodePudding user response:

you can use timer in initState

var data = { name: "alex", time: 3 };

    timer = new Timer.periodic(new Duration(days: data['time']), (Timer timer) async {
        setState(() {
          name = "something"
        });
    });

it will execute after 7 days

CodePudding user response:

use Laravel Task Scheduling:

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        // change "Milo" to "Cola" here

    })->daily();
}
  • Related