Laravel How to delete database data after 5 minutes of adding?
Schema::create('listings', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('country');
$table->string('date');
$table->timestamps();
});
Laravel How to delete database data after 5 minutes of adding?
Schema::create('listings', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('country');
$table->string('date');
$table->timestamps();
});
2
Answers
You can use cron job for this. You have to set cron job time to execute after 5 minutes and removed database which was created before 5 minutes.
Please refere:-
https://laravel.com/docs/9.x/scheduling
Just use this in the scheduler.(or can call a event)
Note: I assumed you have a model called
Listing
or change according to it.