33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Repositories\PricingTierRepository;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* Публичный (без auth) список текущей тарифной сетки для страницы цен.
|
|
*
|
|
* Read-only, без ПДн. Переиспользует PricingTierRepository::activeAt.
|
|
* Требование ЮKassa: цены должны быть публично доступны на сайте.
|
|
*/
|
|
class PublicPricingController extends Controller
|
|
{
|
|
public function index(PricingTierRepository $repo): JsonResponse
|
|
{
|
|
$tiers = $repo->activeAt(CarbonImmutable::now())
|
|
->map(fn ($t) => [
|
|
'tier_no' => (int) $t->tier_no,
|
|
'leads_in_tier' => $t->leads_in_tier === null ? null : (int) $t->leads_in_tier,
|
|
'price_rub' => number_format((int) $t->price_per_lead_kopecks / 100, 2, '.', ''),
|
|
])
|
|
->values();
|
|
|
|
return response()->json(['tiers' => $tiers]);
|
|
}
|
|
}
|