<?php
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../bootstrap/app.php';

use App\Models\User;
use App\Models\Order;
use App\Models\Commission;

echo "User 7 (member):\n";
$u7 = User::find(7);
echo "  - sponsor_id: {$u7->sponsor_id}\n";

echo "\nUser 6 (sponsor level 1):\n";
$u6 = User::find(6);
echo "  - sponsor_id: {$u6->sponsor_id}\n";

echo "\nUser 8 (sponsor level 2):\n";
$u8 = User::find(8);
echo "  - sponsor_id: {$u8->sponsor_id}\n";

echo "\nOrder 10 (la 2ème commande):\n";
$o10 = Order::find(10);
echo "  - user_id: {$o10->user_id} (buyer = member)\n";

echo "\nCommissions on Order 10:\n";
$comms = Commission::where('order_id', 10)->get();
$comms->each(function($c) {
    echo "  - user_id: {$c->user_id}, level: {$c->level}, amount: {$c->amount}\n";
});
