@extends('admin.layout') @php $isNew = !$item->exists; @endphp @section('title', ($isNew ? 'Add ' : 'Edit ') . $d['label']) @section('content')

{{ $isNew ? 'Add' : (($d['readonly'] ?? false) ? 'View' : 'Edit') }} — {{ $d['label'] }}

← Back
@if(!empty($d['show']) && !$isNew)
@foreach($d['show'] as $col => $label)
{{ $label }}
@php $v = $item->{$col}; @endphp {{ is_bool($v) ? ($v ? 'Yes' : 'No') : ($v instanceof \Carbon\Carbon ? $v->format('Y-m-d H:i') : $v) }}
@endforeach
@endif
@csrf @unless($isNew) @method('PUT') @endunless @foreach($d['fields'] as $name => $f) @php $val = old($name, $item->exists ? $item->{$name} : ($f['default'] ?? null)); if (($f['type'] ?? '') === 'lines') { $val = old($name, is_array($item->{$name} ?? null) ? implode("\n", $item->{$name}) : ''); } if (in_array($f['type'], ['date'], true) && $val instanceof \Carbon\Carbon) { $val = $val->format('Y-m-d'); } if ($f['type'] === 'datetime' && $val instanceof \Carbon\Carbon) { $val = $val->format('Y-m-d\TH:i'); } if ($f['type'] === 'datetime' && !$val && $isNew) { $val = now()->format('Y-m-d\TH:i'); } @endphp
@if($f['type'] === 'checkbox') @else @switch($f['type']) @case('textarea') @break @case('lines') @break @case('select') @break @case('image') @if($item->exists && $item->{$name})@endif @break @case('date') @break @case('datetime') @break @case('number') @break @default @endswitch @endif
@endforeach
@endsection