my project in laravel 5.5 and mysql have a start and end date for users to register in my web site When the time ends on a date determined by the administrator, the following function must be executed in laravel:
public function select()
{
seleccion::create([
'emp_id' => Carbon\Carbon::now()->format('Y-m-d'),
'dst_id' => 'Success',
]);
}
I read the laravel documentation but I do not know what to use
those methods do not tell me how to execute a function once on a certain date.
Assuming that there's a single date upon which this function needs to execute, I would simply schedule an Artisan Command
You'd first have to create a command, which you can do by running:
php artisan make:command ExpireRegistrations
Then you'd add your code to the handle()
method of the command
Then you would schedule the command to be executed on the date you require, by adding it to App/Console/Kernel.php
See the laravel docs for the scheduling syntax: https://laravel.com/docs/5.5/scheduling#schedule-frequency-options
Lastly, you'll want to ensure that the Laravel Cron job is set to run on your server by adding this to your Cron Tab:
* * * * * php /path-to-your-project/artisan schedule: