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

$ctrl = app('App\Http\Controllers\PublikController');

$queries = [
    'Masjid Al Ihsan',
    'Masjid Jami Depok',
    'Masjid Istiqlal Jakarta',
    'Masjid Pondok Petir Bojongsari',
];

foreach ($queries as $query) {
    $req  = Illuminate\Http\Request::create('/api/geocode', 'GET', ['q' => $query]);
    $resp = $ctrl->geocode($req);
    $data = json_decode($resp->getContent(), true);
    echo "=== \"$query\" ===\n";
    echo "Hasil: " . count($data['results']) . " lokasi\n";
    foreach (array_slice($data['results'], 0, 3) as $r) {
        echo "  • {$r['name']} | {$r['detail']}\n";
        echo "    lat={$r['lat']}, lng={$r['lng']}\n";
    }
    echo "\n";
}
