@php
    $plans = \App\Models\Plan::active()->with('time')->featured()->orderBy('fixed_amount', 'ASC');
    $plansContent = getContent('plans.content', true);
    $gatewayCurrency = null;

    if (auth()->check()) {
        $gatewayCurrency = App\Models\GatewayCurrency::whereHas('method', function ($gate) {
            $gate->where('status', Status::ENABLE);
        })
            ->with('method')
            ->orderby('method_code')
            ->get();
    }

    $showViewMoreBtn = $plans->count() > 8;
    $plans = $plans->limit(8)->get();
@endphp
<section class="pt-120 pb-120">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-6 text-center">
                <div class="section-header pb-60">
                    <h2 class="section-title text--base">{{ __(@$plansContent->data_values->heading) }}</h2>
                    <p>{{ __(@$plansContent->data_values->subheading) }}</p>
                </div>
            </div>
        </div>
        <div class="row justify-content-center mb-none-70">
            @foreach ($plans as $plan)
                <div class="col-xl-3 col-lg-4 col-sm-6 mb-70 wow fadeInUp" data-wow-duration="0.5s" data-wow-delay="0.1s">
                    <x-plan :plan="$plan" />
                </div>
            @endforeach
        </div>

        @if (@$showViewMoreBtn)
            <div class="row mt-50">
                <div class="col-lg-12 text-center">
                    <a href="{{ route('plans') }}" class="btn btn--base">@lang('View All Plans')</a>
                </div>
            </div>
        @endif
    </div>
</section>

<x-plan-modal :gateways="$gatewayCurrency" />
