Feat: Updating Home, Product and Category Controllers and veiws to utilize the product service

This commit is contained in:
2026-08-27 00:55:56 +03:00
parent 65205e2760
commit b3405c1b60
7 changed files with 83 additions and 93 deletions
@@ -1,29 +1,32 @@
{{-- $variants: array of Modules\Core\Search\ProductIndexer's mapVariant() shape
(id, options: [{option, value, meta}], ...) — plain arrays, not Eloquent
models, since this is fed from Modules\Core\Catalog\ProductService. --}}
@props(['variants', 'option' => null])
<div {{ $attributes }}>
@if($option)
<p class="font-bold mb-3 text-sm uppercase tracking-wide">
{{ $option->translate('name') }}: <span data-product-form-target="colorName" class="font-normal normal-case"></span>
{{ $option }}: <span data-product-form-target="colorName" class="font-normal normal-case"></span>
</p>
@endif
<div
class="flex flex-wrap gap-2"
role="group"
aria-label="{{ $option?->translate('name') ?? 'Color' }}"
aria-label="{{ $option ?? 'Color' }}"
>
@foreach($variants as $variant)
@php
$value = $variant->values->first();
$label = $value?->translate('name') ?? '';
$bg = $value?->meta['hex'] ?? '#cccccc';
$value = $variant['options'][0] ?? null;
$label = $value['value'] ?? '';
$bg = $value['meta']['hex'] ?? '#cccccc';
@endphp
<button
type="button"
class="color-swatch"
data-product-form-target="swatch"
data-action="click->product-form#selectVariant"
data-variant-id="{{ $variant->id }}"
data-variant-id="{{ $variant['id'] }}"
style="background-color: {{ $bg }};"
aria-label="{{ $label }}"
aria-pressed="false"