<?php
// Bootstrap commun à tous les crons
define('BASE_PATH', dirname(__DIR__));
require_once BASE_PATH . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(BASE_PATH);
$dotenv->load();
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection([
    'driver' => 'mysql', 'host' => $_ENV['DB_HOST'], 'port' => $_ENV['DB_PORT'] ?? 3306,
    'database' => $_ENV['DB_NAME'], 'username' => $_ENV['DB_USER'],
    'password' => $_ENV['DB_PASS'], 'charset' => 'utf8mb4',
]);
if (!empty($_ENV['DB_WORK_NAME'])) {
    $capsule->addConnection([
        'driver' => 'mysql', 'host' => $_ENV['DB_WORK_HOST'], 'port' => $_ENV['DB_WORK_PORT'] ?? 3306,
        'database' => $_ENV['DB_WORK_NAME'], 'username' => $_ENV['DB_WORK_USER'],
        'password' => $_ENV['DB_WORK_PASS'], 'charset' => 'utf8mb4',
    ], 'workflow');
}
$capsule->setAsGlobal();
$capsule->bootEloquent();
