@extends('layouts.demo10.base') @section('styles') @endsection @section('content') @php $packageModel = $package ?? null; $isEdit = ! blank($packageModel); $selectedModuleIds = old('modules'); $oldOrDefault = static function (string $key, $default) { $value = old($key); return blank($value) ? $default : $value; }; if (! is_array($selectedModuleIds) || empty($selectedModuleIds)) { $selectedModuleIds = $isEdit ? $packageModel->modules->pluck('id')->map(fn ($id) => (string) $id)->all() : []; } $packageNameValue = $oldOrDefault('name', $packageModel->name ?? ''); $packageTagValue = $oldOrDefault('tag', data_get($packageModel?->meta, 'tag', '')); $packageDescriptionValue = $oldOrDefault('description', $packageModel->description ?? ''); $monthlyPriceValue = $oldOrDefault('monthly_price', $isEdit ? number_format((float) ($packageModel->monthly_price ?? $packageModel->price), 0, '.', '') : ''); $yearlyPriceValue = $oldOrDefault('yearly_price', $isEdit ? number_format((float) ($packageModel->yearly_price ?? ((float) ($packageModel->monthly_price ?? $packageModel->price) * 12)), 0, '.', '') : ''); $yearlyDiscountValue = $oldOrDefault('yearly_discount', $isEdit ? (string) ($packageModel->yearly_discount ?? 0) : ''); $monthlyEnabledValue = filled(old('monthly_enabled')) ? true : ($isEdit ? (($packageModel->billing_cycle ?? 'monthly') === 'monthly') : true); $yearlyEnabledValue = filled(old('yearly_enabled')) ? true : ($isEdit ? (($packageModel->billing_cycle ?? 'monthly') === 'yearly') : false); $trialEnabledValue = filled(old('trial_enabled')) ? old('trial_enabled') : ($packageModel->trial_enabled ?? false); $initialIconUrl = $isEdit && ! blank($packageModel->icon_path) ? asset('storage/' . ltrim($packageModel->icon_path, '/')) : ''; $initialIconLabel = $isEdit && ! blank($packageModel->icon_path) ? basename($packageModel->icon_path) : ''; @endphp
@endsection @section('scripts') @vite('resources/js/pages/packages.js') @endsection