feat: implement currency rates tracking with models, migrations and views

هذا الالتزام موجود في:
2025-05-24 05:59:12 +03:00
الأصل 72b4eff3ee
التزام b19748ef20
21 ملفات معدلة مع 690 إضافات و361 حذوفات

عرض الملف

@@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers;
use App\Models\City;
use App\Models\Rate;
class RateController extends Controller
{
public function __invoke()
{
$supportedCities = City::query()
->whereIn('name', City::supportedCities())
->get()
->sortByDesc(fn ($city) => $city->name === 'sanaa')
->values();
$rates = Rate::query()
->with('currency', 'city')
->orderBy('city_id', 'asc')
->orderBy('currency_id', 'asc')
->orderBy('date', 'desc')
->get()
->groupBy(fn ($rate) => $rate->city_id.'-'.$rate->currency_id)
->map(fn ($group) => $group->first())
->groupBy('city_id');
return view('rates', [
'rates' => $rates,
'supportedCities' => $supportedCities,
]);
}
}