Estado inicial: frontend React + backend Laravel
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Workshop;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
class UpdateWorkshopStatus extends Command
|
||||
{
|
||||
protected $signature = 'workshops:update-status';
|
||||
protected $description = 'Atualiza o estado de workshops agendados para realizados se a data for menor que a data atual';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$update = Workshop::where(function($query){
|
||||
$query->where('date', '<', now()->toDateString())
|
||||
->orWhere(function($q){
|
||||
$q->where('date', '=', now()->toDateString())
|
||||
->where('time_end', '<', now()->toTimeString());
|
||||
});
|
||||
})
|
||||
->where('status', 'pending')
|
||||
->update(['status' => 'realized']);
|
||||
$this->info('Workshops atualizados com sucesso');
|
||||
}
|
||||
}
|
||||
28
plataforma-tutorias/app/Console/Kernel.php
Normal file
28
plataforma-tutorias/app/Console/Kernel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->command('workshops:update-status')->everyMinute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user