ifnex/04_Laravel/app/Http/Controllers/PricingPageController.php
Kazem Alghasi 499e0731b1 feat(pricing): centralize exchange rate management via ExchangeRateService
Migrate exchange rate handling from static system settings to a
centralized `ExchangeRateService`. This change ensures that currency
rates are managed through a single source of truth that supports
history tracking, approval workflows, and API updates.

Laravel:
- Remove manual exchange rate fields (`aed_to_irr`, `usd_to_irr`, etc.)
  from `IfnexSettingsPage` and the `SystemSetting` persistence logic.
- Update `PricingPageController` and `PriceCalculatorService` to
  retrieve live rates from `ExchangeRateService` instead of `SystemSetting`.
- Refactor `IfnexSettingsPage` UI to display current rates as
  read-only information with a link to the dedicated exchange rate
  management resource.

Documentation:
- Update `CLIENT_DELIVERY.md` to reflect the change in exchange rate
  management workflow.
2026-10-03 07:20:32 +03:30

23 lines
663 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Country;
use App\Models\SystemSetting;
use Illuminate\Http\Request;
class PricingPageController extends Controller
{
public function __invoke()
{
$countries = Country::orderBy('name')->get(['id', 'name', 'iso_code']);
$settings = [
'aed_to_irr' => app(\App\Services\ExchangeRateService::class)->getCurrentRate('AED', 'IRR'),
'profit_margin' => (float) SystemSetting::get('profit_margin', 1.25),
'vat_rate' => (float) SystemSetting::get('vat_rate', 0.09),
];
return view('pricing.index', compact('countries', 'settings'));
}
}