@extends('backEnd.master') @section('title') @lang('academics.discount_plan') @endsection @section('mainContent')
@if (isset($discountPlan)) @if (userPermission('discount_plans-store')) @endif @endif
@if (isset($discountPlan)) {{ Form::open(['class' => 'form-horizontal', 'files' => true, 'route' => ['discount_plans-update', $discountPlan->id], 'method' => 'PUT', 'enctype' => 'multipart/form-data']) }} @else @if (userPermission('discount_plans-store')) {{ Form::open([ 'class' => 'form-horizontal', 'files' => true, 'route' => 'discount_plans-store', 'method' => 'POST', 'enctype' => 'multipart/form-data', ]) }} @endif @endif

@if (isset($discountPlan)) @lang('academics.edit_discount_plan') @else @lang('academics.add_discount_plan') @endif

@if ($errors->has('name_en')) {{ $errors->first('name_en') }} @endif
@if ($errors->has('name_ar')) {{ $errors->first('name_ar') }} @endif
{{-- Repeated sections --}}
@if (isset($discountPlan->levels_prices) && is_array($discountPlan->levels_prices)) @foreach ($discountPlan->levels_prices as $index => $levelPrice)
@endforeach @else
@if ($errors->has('level_id')) {{ $errors->first('level_id') }} @endif
@if ($errors->has('price')) {{ $errors->first('price') }} @endif
@endif
@php $tooltip = ''; if (userPermission('discount_plans-store')) { $tooltip = ''; } elseif (isset($discountPlan) && userPermission('discount_plans-edit')) { $tooltip = ''; } else { $tooltip = 'You have no permission to add'; } @endphp
{{ Form::close() }}

@lang('academics.discount_plan_list')

{{-- --}} @foreach ($discountPlans as $discountPlan) @endforeach
@lang('academics.level_number')@lang('academics.levels_prices') @lang('academics.name_en') @lang('academics.name_ar') @lang('common.action')
@php $levelsPrices = array_map(function ($levelPrice) use ( $levels, ) { $levelNumber = $levels ->where('id', $levelPrice['level_id']) // ->pluck('level_number'); ->first()->level_number ?? 'N/A'; return 'Level ID: ' . $levelNumber . ', Price: ' . $levelPrice['price']; }, $discountPlan->levels_prices); echo implode('
', $levelsPrices); @endphp
{{ $discountPlan->name_en }} {{ $discountPlan->name_ar }} @if (userPermission('discount_plans-edit')) @lang('common.edit') @endif @if (userPermission('discount_plans-delete')) @lang('common.delete') @endif
@endsection @push('scripts') @endpush @include('backEnd.partials.data_table_js')