<?php

require __DIR__ . '/../vendor/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

use App\Models\Category;
use App\Models\Subcategory;
use App\Models\Product;

$categories = Category::all();
foreach ($categories as $cat) {
    echo "CAT: " . $cat->id . "|" . $cat->name . " (" . $cat->products()->count() . ")" . PHP_EOL;
    foreach ($cat->subcategories as $sub) {
        $count = Product::where('subcategory_id', $sub->id)->count();
        echo "  SUB: " . $sub->id . "|" . $sub->subcategoryName . " (" . $count . ")" . PHP_EOL;
    }
}
