53 lines
1.7 KiB
PHP
Executable File
53 lines
1.7 KiB
PHP
Executable File
<?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
|
|
{
|
|
//Para atualizar a fObra para execussao quando chegar na hora estipulada.
|
|
$schedule->call(function () {
|
|
\App\Models\CompanyProject::where('order_project', 2)
|
|
->where('date_started', '<=', now())
|
|
->update(['order_project' => 3]);
|
|
})->everyMinute(); // Ou ajuste para a frequência desejada
|
|
|
|
|
|
//Funcao para libertar equipamentos na control caso nao seja atualizado em 1 minuto
|
|
$schedule->call(function () {
|
|
// Define o limite de inatividade, por exemplo, sessões não atualizadas nos últimos 1 minutos
|
|
$inactiveLimit = now()->subMinutes(1);
|
|
|
|
// Atualiza sessões inativas
|
|
\App\Models\ControlEquipmentWorkstation::where('status', 1)
|
|
->whereNull('departure_date')
|
|
->where('last_active_at', '<', $inactiveLimit)
|
|
->update([
|
|
'status' => 0,
|
|
'id_workstations' => null,
|
|
'elemental_tasks_id' => null,
|
|
'entry_date' => null,
|
|
]);
|
|
|
|
// Adicione outras tarefas necessárias aqui
|
|
})->everyMinute();
|
|
}
|
|
|
|
/**
|
|
* Register the commands for the application.
|
|
*/
|
|
protected function commands(): void
|
|
{
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
require base_path('routes/console.php');
|
|
}
|
|
}
|