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

use App\Models\Product;
use App\Models\ProductSize;

$names = ['Celana Jeans Slim-fit', 'Celana Chino Pria'];
foreach ($names as $name) {
    $product = Product::where('name', $name)->first();
    echo "Product: {$name}\n";
    if (!$product) {
        echo "  NOT FOUND\n";
        continue;
    }
    echo "  ID={$product->id}\n";
    $rows = ProductSize::on('sizes_db')->where('product_id', $product->id)->orderBy('size')->get();
    foreach ($rows as $row) {
        echo "  size={$row->size} stock={$row->stock}\n";
    }
}
