I have a table in a mysql database and i want to every midnight set a row in that table to false.
How would i go about doing this?
You can setup a task to run at midnight and do whatever you want to do in that task. Check out the docs for task scheduling here.
Create a controller function and execute it at midnight. Lets say you have ScheduleController
class ScheduleController extends Controller {
public function resetDataBase()
{
//write query here to change the table row.
//You may use raw queries
}
}
Then call this function in App\Console\Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->call('\App\Http\Controllers\ScheduleController@resetDataBase')
->dailyAt('00:00');
}
On the server where you have hosted the application, you have to setup a crontab
entry
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
Refer docs for more info.