@php $isEdit = isset($portfolio) && $portfolio->exists && $portfolio->id; $formAction = $isEdit ? route('admin.portfolios.update', $portfolio->id) : route('admin.portfolios.store'); $formMethod = $isEdit ? 'PUT' : 'POST'; $formTitle = $isEdit ? 'Edit Portfolio Project' : 'Create Portfolio Project'; $submitText = $isEdit ? 'Update Project' : 'Save Project'; // ✅ FIX: Ensure gallery_images is always an array $galleryImages = []; if (isset($portfolio) && $portfolio->exists) { $galleryImages = $portfolio->gallery_images ?? []; if (is_string($galleryImages)) { $galleryImages = json_decode($galleryImages, true) ?? []; } if (!is_array($galleryImages)) { $galleryImages = []; } } // ✅ FIX: Ensure technologies is always an array $technologies = []; if (isset($portfolio) && $portfolio->exists) { $technologies = $portfolio->technologies ?? []; if (is_string($technologies)) { $technologies = json_decode($technologies, true) ?? []; } if (!is_array($technologies)) { $technologies = []; } } @endphp @if ($errors->any())
Validation Errors!
@endif

{{ $formTitle }}

Back to List
@csrf @if($isEdit) @method('PUT') @endif
Basic Information
@error('title') {{ $message }} @enderror
{{ url('/') }}/portfolio/
@error('slug') {{ $message }} @enderror
Preview: @if(isset($portfolio) && $portfolio->slug) {{ $portfolio->slug }} @else auto-generated @endif
@error('category') {{ $message }} @enderror
@error('client') {{ $message }} @enderror
@error('description') {{ $message }} @enderror
@php $techs = old('technologies', $technologies); if (is_string($techs)) { $techs = json_decode($techs, true) ?? []; } if (!is_array($techs)) { $techs = []; } @endphp @if(!empty($techs) && is_array($techs)) @foreach($techs as $index => $tech)
@endforeach @else
@endif
Add each technology separately
@error('project_url') {{ $message }} @enderror
SEO Settings
Optional
@error('meta_title') {{ $message }} @enderror
@error('meta_description') {{ $message }} @enderror
@error('meta_keywords') {{ $message }} @enderror
Images
@if(isset($portfolio) && $portfolio->featured_image)
Featured Image
Current Image
Click below to change
@else

Click to upload featured image

PNG, JPG, WEBP (Max 2MB)
@endif
@error('featured_image') {{ $message }} @enderror Recommended: 1200 x 800 pixels
@error('gallery_images.*') {{ $message }} @enderror Max 2MB each. Select multiple images @if(!empty($galleryImages) && is_array($galleryImages)) @endif
Status & Settings
@error('status') {{ $message }} @enderror
is_featured ?? 0) ? 'checked' : '' }} style="width: 18px; height: 18px; accent-color: #C1121F; cursor: pointer;">
Featured projects appear on the homepage
@error('sort_order') {{ $message }} @enderror Lower numbers appear first
@php $user = Auth::guard('admin')->user(); $isAdmin = $user && ($user->id == 1 || $user->role_id == 1); // Super Admin OR Admin (role_id=1) $isUser = $user && $user->role_id == 4; // User (role_id=4) @endphp @if(isset($portfolio) && $portfolio->exists) {{-- ===== EDIT MODE ===== --}} @if($portfolio->isLocked()) @else @if($isAdmin) @elseif($isUser) Your changes will be sent for approval. @endif @endif @else {{-- ===== CREATE MODE ===== --}} @if($isAdmin) @elseif($isUser) Your portfolio will be sent for approval before publishing. @endif @endif Cancel @if(!isset($portfolio) || !$portfolio->isLocked()) @endif