@php
/** @var \V2\Modules\Conexoes\UnidadeRegional\Models\UnidadeRegional|null $unidade */
$unidade = $unidade ?? null;
$isEditing = $unidade && $unidade->exists;
$ufs = [
'AC','AL','AP','AM','BA','CE','DF','ES','GO',
'MA','MT','MS','MG','PA','PB','PR','PE','PI',
'RJ','RN','RS','RO','RR','SC','SP','SE','TO',
];
$meta = $unidade->metadata ?? [];
$storageSvc = app(\V2\Services\Storage\StorageService::class);
$allTags = \V2\Core\Models\ConexaoTag::orderBy('name')->get();
$selectedTags = old('tags', $isEditing && $unidade->relationLoaded('tags') ? $unidade->tags->pluck('name')->toArray() : []);
// Redes sociais existentes convertidas para JSON do builder (SEM site — campo independente)
$defaultSocial = [
['network' => 'linkedin', 'icon' => 'bi-linkedin', 'url' => '', 'order' => 1, 'active' => true],
['network' => 'facebook', 'icon' => 'bi-facebook', 'url' => '', 'order' => 2, 'active' => true],
['network' => 'instagram', 'icon' => 'bi-instagram', 'url' => '', 'order' => 3, 'active' => true],
];
$urSocialInit = [];
if ($meta['linkedin_url'] ?? '') $urSocialInit[] = ['network'=>'linkedin', 'url'=>$meta['linkedin_url'], 'icon'=>'bi-linkedin', 'order'=>1, 'active'=>true];
if ($meta['facebook_url'] ?? '') $urSocialInit[] = ['network'=>'facebook', 'url'=>$meta['facebook_url'], 'icon'=>'bi-facebook', 'order'=>2, 'active'=>true];
if ($meta['instagram_url'] ?? '') $urSocialInit[] = ['network'=>'instagram','url'=>$meta['instagram_url'], 'icon'=>'bi-instagram','order'=>3, 'active'=>true];
$urSocialInitJson = json_encode(!empty($urSocialInit) ? $urSocialInit : $defaultSocial);
@endphp
@push('css')
@endpush
{{-- ============================================= --}}
{{-- SEÇÃO 1: METADADOS --}}
{{-- ============================================= --}}
{{-- Linha 1: Nome + Sigla + UF --}}
@if($errors->has('name'))
{{ $errors->first('name') }}
@endif
@if($errors->has('acronym'))
{{ $errors->first('acronym') }}
@endif
@if($errors->has('state'))
{{ $errors->first('state') }}
@endif
{{-- Tags --}}
@if(!empty($selectedTags))
@foreach($selectedTags as $tagName)
{{ $tagName }}
@endforeach
@endif
@if($allTags->isNotEmpty())
@foreach($allTags as $tag)
@endforeach
Clique em uma tag disponível para adicioná-la.
@endif
{{-- Linha 2: Cidade + Telefone + E-mail --}}
@if($errors->has('city'))
{{ $errors->first('city') }}
@endif
@if($errors->has('phone'))
{{ $errors->first('phone') }}
@endif
@if($errors->has('email'))
{{ $errors->first('email') }}
@endif
{{-- Linha 3: Endereço + Coordenadas --}}
@if($errors->has('address'))
{{ $errors->first('address') }}
@endif
@if($errors->has('map_coordinates'))
{{ $errors->first('map_coordinates') }}
@endif
{{-- Linha 4: Site + Redes Sociais --}}
{{-- Hidden inputs mantidos para compatibilidade com o controller --}}
{{-- Linha 5: Ativo --}}
{{-- ============================================= --}}
{{-- SEÇÃO 2: CONTEÚDO (Logo + Cover) --}}
{{-- ============================================= --}}
Logo
@include('v2-service-media::components.media-input', [
'name' => 'logo_id',
'label' => 'Logo',
'accept' => 'image/*',
'required' => false,
'ownerModule' => 'unidade-regional',
'currentId' => $meta['logo_id'] ?? '',
'currentUrl' => $isEditing && $unidade->logo ? v2_storage_url($unidade->logo) : '',
'currentAlt' => $unidade->name ?? '',
])
Imagem de Fundo (Hero)
@include('v2-service-media::components.media-input', [
'name' => 'cover_image_id',
'label' => 'Imagem de Fundo',
'accept' => 'image/*',
'required' => false,
'ownerModule' => 'unidade-regional',
'currentId' => $meta['cover_image_id'] ?? '',
'currentUrl' => $isEditing && !empty($meta['cover_image']) ? v2_storage_url($meta['cover_image']) : '',
'currentAlt' => $unidade->name ?? '',
'help' => 'Recomendado: 1920×400px, formato landscape. Usada como fundo do cabeçalho da página.',
])
@push('scripts')
@endpush