Files
portal/app/app/Http/Controllers/Api/PublicPricingController.php
T
Дмитрий 146174a2e2
Accessibility (Pa11y live) / a11y (push) Has been cancelled
SAST — Semgrep / Semgrep SAST scan (push) Has been cancelled
feat: публичные юр-страницы оферта/политика/возврат + реквизиты + страница цен под модерацию ЮKassa
2026-06-24 09:31:52 +03:00

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]);
}
}