<?php
$models = [
    'User' => 'users',
    'Ruangan' => 'ruangan',
    'SumberDana' => 'sumber_dana',
    'JenisBarang' => 'jenis_barang',
    'Barang' => 'barang',
    'Tanah' => 'tanah',
    'Bangunan' => 'bangunan',
    'Buku' => 'buku',
    'Peminjaman' => 'peminjaman',
    'Perbaikan' => 'perbaikan',
    'Pengajuan' => 'pengajuan',
    'Penghapusan' => 'penghapusan'
];

foreach ($models as $name => $table) {
    $content = "<?php\n\nnamespace App\Models;\n\nuse CodeIgniter\Model;\n\nclass {$name}Model extends Model\n{\n    protected \$table            = '{$table}';\n    protected \$primaryKey       = 'id';\n    protected \$useAutoIncrement = true;\n    protected \$returnType       = 'array';\n    protected \$useSoftDeletes   = false;\n    protected \$protectFields    = false; // allow all\n\n    // Dates\n    protected \$useTimestamps = true;\n    protected \$dateFormat    = 'datetime';\n    protected \$createdField  = 'created_at';\n    protected \$updatedField  = 'updated_at';\n}\n";
    file_put_contents(__DIR__ . "/app/Models/{$name}Model.php", $content);
}

echo "Models created successfully!\n";
