<?php

require_once 'vendor/autoload.php';

use Illuminate\Database\Capsule\Manager as Capsule;

// Configuration de la base de données
$capsule = new Capsule;
$capsule->addConnection([
    'driver' => 'pgsql',
    'host' => '127.0.0.1',
    'database' => 'gstock',
    'username' => 'postgres',
    'password' => 'password',
    'charset' => 'utf8',
    'prefix' => '',
    'schema' => 'public',
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();

try {
    // Vérifier si la table checks existe
    $checks = Capsule::table('checks')->get();
    echo "Nombre de chèques: " . count($checks) . "\n";
    
    if (count($checks) > 0) {
        echo "Premier chèque: " . json_encode($checks[0]) . "\n";
    }
    
    // Vérifier les chèques non utilisés
    $unusedChecks = Capsule::table('checks')->where('status', 'unused')->get();
    echo "Chèques non utilisés: " . count($unusedChecks) . "\n";
    
} catch (Exception $e) {
    echo "Erreur: " . $e->getMessage() . "\n";
}