File: /var/www/vhost/disk-apps/agile-selling-orl/app/Console/Kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Parameter;
use DB;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$bo_default_warehouse = $this->getCurrentWarehouse();
// IGT
$schedule->command('b1:sync')->cron('0 0 * * *'); // Todos los días media noche
// $schedule->command('b1:sync-inventory', [$bo_default_warehouse])->everyFiveMinutes(); // Cada 5 minutos
$schedule->command('b1:sync-inventory', [$bo_default_warehouse])->cron('0 18 * * *'); // Todos los días a las 6 pm
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
function getCurrentWarehouse(){
$parameters = Parameter::first();
$warehouse = DB::connection('main-db')->table('service_cities')->where('name_database', $parameters->db_name)->first();
return $warehouse->bo_default_warehouse;
}
}