@extends('admin.layouts.app') @section('page-title', 'Categories') @section('body-class', 'categories-preview') @push('styles') @endpush @push('scripts') @endpush @section('content') @php $field = static fn ($key, $fallback = '') => is_scalar(old($key, $fallback)) ? old($key, $fallback) : $fallback; $imageSource = $field('image_source', request()->query('cover_picker') === '1' || $category?->product_image_id ? 'product' : 'upload'); @endphp

Categories {{ $categories->total() }}

Add
@if($category) @endif
@csrf @if($category) @method('PATCH') @endif

{{ $category ? 'Edit category' : 'New category' }}

Database
@if(session('status'))

{{ session('status') }}

@endif @if($errors->any()) @endif
has('name')) aria-invalid="true" @endif>
Homepage placement

Smaller numbers appear first. Equal positions sort by category name.

@if($category)
Choose from this category's products @if($selectedImage && !$productImages->getCollection()->contains('id', $selectedImage->id))

Current selection

@endif
@forelse($productImages as $image) @empty

No matching product images in this category.

@endforelse
@if($productImages->hasPages()) @endif

Only products assigned to this category are shown. Save to apply your selection.

@else

Save the category first, then add products to choose one of their photos.

@endif
JPG, PNG or WebP. Up to 5 MB and 6000 × 6000 pixels. Leave blank to keep the uploaded cover.
@if($category?->cover_path) View uploaded cover @endif

An uploaded cover is kept as a fallback when a selected product photo is removed or its product moves to another category.

Reset changes

Category cover

coverPath()) src="{{ route('admin.products.categories.cover', $category) }}?v={{ $category->version }}" @else hidden @endif alt="Category cover">coverPath()) hidden @endif>Select an image to preview

Homepage order preview

Saved order
@foreach($placements as $placement => $label)
{{ $label }}
@forelse($homepageCategories[$placement] as $item)
{{ $loop->iteration }}{{ $item->name }}
@empty

No categories in this area

@endforelse
@endforeach

Saved configuration. The storefront will use this when its API connection is added.

@endsection