MIF_E31231754/get_ranking.php

18 lines
581 B
PHP

<?php
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
$top = App\Models\HasilSaw::with('warga')->orderBy('ranking')->take(3)->get();
echo "TOP:\n";
foreach($top as $t) {
echo $t->warga->nama . " (" . number_format($t->skor_akhir, 3) . ")\n";
}
$bot = App\Models\HasilSaw::with('warga')->orderByDesc('ranking')->take(1)->get();
echo "BOTTOM:\n";
foreach($bot as $b) {
echo $b->warga->nama . " (" . number_format($b->skor_akhir, 3) . ")\n";
}