3 Commits
19 changed files with 144 additions and 225 deletions
+5 -7
View File
@@ -119,13 +119,11 @@ COPY docker/php/php.dev.ini /etc/php/8.5/cli/conf.d/99-app.ini
WORKDIR /var/www/html WORKDIR /var/www/html
COPY composer.json composer.lock ./ # No build-time `composer install` here: composer.json's boboko/core path repo
RUN composer install \ # (../boboko-core) isn't visible in the build context, only once bind-mounted at
--no-interaction \ # container start — entrypoint.sh already runs composer install +
--no-scripts \ # composer update boboko/* on every boot, so this would be redundant even if it
--prefer-dist \ # could work.
--ignore-platform-reqs
COPY docker/entrypoint.sh /entrypoint.sh COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/entrypoint-worker.sh /entrypoint-worker.sh COPY docker/entrypoint-worker.sh /entrypoint-worker.sh
RUN chmod +x /entrypoint.sh /entrypoint-worker.sh RUN chmod +x /entrypoint.sh /entrypoint-worker.sh
+12 -23
View File
@@ -2,10 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Pagination\LengthAwarePaginator;
use Lunar\Models\Collection; use Lunar\Models\Collection;
use Modules\Core\Catalog\ProductFilters; use Modules\Core\Product\DTOs\ProductFilters;
use Modules\Core\Catalog\ProductService; use Modules\Core\Product\Services\ProductService;
class CategoryController extends Controller class CategoryController extends Controller
{ {
@@ -19,29 +18,19 @@ public function show(string $locale, Collection $collection)
$page = (int) request('page', 1); $page = (int) request('page', 1);
// Listing/filtering reads from the Meilisearch index via ProductService, // Listing/filtering reads from the Meilisearch index via ProductService,
// not Eloquent — see Modules\Core\Catalog\ProductService. It returns plain // not Eloquent — see Modules\Core\Product\Services\ProductService. list() returns a
// arrays (already localized/flattened), not Product models. // real LengthAwarePaginator of plain arrays (already localized/flattened),
$result = $this->products->list( // not Product models.
$products = $this->products->list(
filters: new ProductFilters(collectionId: $collection->id), filters: new ProductFilters(collectionId: $collection->id),
perPage: $perPage, perPage: $perPage,
page: $page, page: $page,
); )->through(fn (array $product) => [
'name' => $product['name'],
$products = new LengthAwarePaginator( 'price' => $product['price'],
items: collect($result['data'])->map(fn (array $product) => [ 'image' => $product['media'][0]['url'] ?? null,
'name' => $product['name'], 'href' => route('product.show', ['id' => $product['id']]),
'price' => $product['price'], ]);
'image' => $product['media'][0]['url'] ?? null,
'href' => route('product.show', ['product' => $product['id']]),
]),
total: $result['meta']['total'],
perPage: $result['meta']['per_page'],
currentPage: $result['meta']['current_page'],
options: [
'path' => request()->url(),
'query' => request()->query(),
],
);
return view('category.show', [ return view('category.show', [
'collection' => $collection, 'collection' => $collection,
+1 -1
View File
@@ -23,7 +23,7 @@ public function index(string $locale)
'name' => $product->translateAttribute('name'), 'name' => $product->translateAttribute('name'),
'price' => $product->variants->first()?->prices->first()?->price->decimal, 'price' => $product->variants->first()?->prices->first()?->price->decimal,
'image' => $product->media->first()?->getUrl(), 'image' => $product->media->first()?->getUrl(),
'href' => route('product.show', ['product' => $product]), 'href' => route('product.show', ['id' => $product->id]),
]); ]);
return view('home', [ return view('home', [
+27 -27
View File
@@ -2,44 +2,44 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Lunar\Models\Product; use Illuminate\Http\Response;
use Lunar\Models\Collection;
use Modules\Core\Product\Services\ProductService;
class ProductController extends Controller class ProductController extends Controller
{ {
public function show(string $locale, Product $product) public function __construct(private readonly ProductService $products) {}
public function show(string $locale, int $id)
{ {
$product->load([ $product = $this->products->getById($id);
"variants.prices.currency",
"variants.values.option",
"media",
"collections",
]);
$option = $product->variants->first()?->values->first()?->option; abort_if($product === null, Response::HTTP_NOT_FOUND);
$variantsData = $product->variants $collection = $product['collections'][0] ?? null;
->map( $collectionModel = $collection !== null ? Collection::find($collection) : null;
fn($v) => [
"id" => $v->id, $variantsData = collect($product['variants'])
"price" => $v->prices->first()?->price->decimal, ->map(fn (array $variant) => [
"image" => null, // variant-level media not differentiated yet 'id' => $variant['id'],
], 'price' => $variant['prices'][0]['price'] ?? null,
) 'image' => $variant['media'][0]['url'] ?? null,
])
->values() ->values()
->toArray(); ->all();
$firstImage = $product->media->first()?->getUrl(); $firstVariant = $product['variants'][0] ?? null;
$option = $firstVariant['options'][0]['option'] ?? null;
// temp categories here // temp categories here
$categories = \Lunar\Models\Collection::orderBy("_lft")->get(); $categories = Collection::orderBy('_lft')->get();
// dd($product); return view('product.show', [
'categories' => $categories,
return view("product.show", [ 'collection' => $collectionModel,
"categories" => $categories, 'product' => $product,
"product" => $product, 'option' => $option,
"option" => $option, 'variantsData' => $variantsData,
"variantsData" => $variantsData,
]); ]);
} }
} }
+16
View File
@@ -16,4 +16,20 @@
'auto_create_customer_for_user' => true, 'auto_create_customer_for_user' => true,
/*
|--------------------------------------------------------------------------
| Product Option Types
|--------------------------------------------------------------------------
|
| Enabled `Modules\Core\Product\Contracts\ProductOptionTypeInterface`
| implementations. An admin picks one per ProductOption from a dropdown
| on the option's own edit form — the selection is stored in
| ProductOption::meta, not tied to the option's handle.
|
*/
'product_option_types' => [
\Modules\Core\Product\OptionTypes\ColorOptionType::class,
],
]; ];
+1 -1
View File
@@ -49,7 +49,7 @@
Lunar\Models\Collection::class => Lunar\Search\CollectionIndexer::class, Lunar\Models\Collection::class => Lunar\Search\CollectionIndexer::class,
Lunar\Models\Customer::class => Lunar\Search\CustomerIndexer::class, Lunar\Models\Customer::class => Lunar\Search\CustomerIndexer::class,
Lunar\Models\Order::class => Lunar\Search\OrderIndexer::class, Lunar\Models\Order::class => Lunar\Search\OrderIndexer::class,
Lunar\Models\Product::class => Modules\Core\Search\ProductIndexer::class, Lunar\Models\Product::class => Modules\Core\Product\Services\ProductIndexer::class,
Lunar\Models\ProductOption::class => Lunar\Search\ProductOptionIndexer::class, Lunar\Models\ProductOption::class => Lunar\Search\ProductOptionIndexer::class,
], ],
-44
View File
@@ -1,44 +0,0 @@
<?php
return [
'nav' => [
'home' => 'Αρχική',
'products' => 'Προϊόντα',
'contact' => 'Επικοινωνία',
],
'product' => [
'description' => 'Περιγραφή',
'reviews' => 'Αξιολογήσεις',
],
// Laravel pluralization: {0} zero|{1} one|[2,*] many. :count is replaced automatically.
'customer_reviews' => '{0} Καμία αξιολόγηση πελάτη|{1} :count αξιολόγηση πελάτη|[2,*] :count αξιολογήσεις πελατών',
'shop' => [
// Laravel pluralization keyed on the total result count.
'showing_results' => '{0} Δεν βρέθηκαν προϊόντα|{1} Εμφάνιση :first–:last από :total αποτέλεσμα|[2,*] Εμφάνιση :first–:last από :total αποτελέσματα',
'no_products' => 'Δεν βρέθηκαν προϊόντα σε αυτή την κατηγορία.',
'search_label' => 'Αναζήτηση προϊόντων',
'search_placeholder' => 'Αναζήτησε προϊόντα…',
'filter_price' => 'Φίλτρο τιμής',
'apply' => 'Εφαρμογή',
'availability' => 'Διαθεσιμότητα',
'in_stock_only' => 'Μόνο διαθέσιμα προϊόντα',
'sort_label' => 'Ταξινόμηση προϊόντων',
'sort_default' => 'Προεπιλεγμένη ταξινόμηση',
'sort_popularity' => 'Δημοφιλή',
'sort_price_asc' => 'Τιμή: Αύξουσα',
'sort_price_desc' => 'Τιμή: Φθίνουσα',
'sort_newest' => 'Νεότερα',
],
'pagination' => [
'nav_label' => 'Σελιδοποίηση',
'page' => 'Σελίδα :page',
'next' => 'Επόμενη σελίδα',
'previous' => 'Προηγούμενη σελίδα',
],
];
-44
View File
@@ -1,44 +0,0 @@
<?php
return [
'nav' => [
'home' => 'Home',
'products' => 'Products',
'contact' => 'Contact',
],
'product' => [
'description' => 'Description',
'reviews' => 'Reviews',
],
// Laravel pluralization: {0} zero|{1} one|[2,*] many. :count is replaced automatically.
'customer_reviews' => '{0} No customer reviews|{1} :count customer review|[2,*] :count customer reviews',
'shop' => [
// Laravel pluralization keyed on the total result count.
'showing_results' => '{0} No products found|{1} Showing :first–:last of :total result|[2,*] Showing :first–:last of :total results',
'no_products' => 'No products found in this category.',
'search_label' => 'Search products',
'search_placeholder' => 'Search products…',
'filter_price' => 'Filter by price',
'apply' => 'Apply',
'availability' => 'Availability',
'in_stock_only' => 'In-stock products only',
'sort_label' => 'Sort products',
'sort_default' => 'Default sorting',
'sort_popularity' => 'Popularity',
'sort_price_asc' => 'Price: Low to High',
'sort_price_desc' => 'Price: High to Low',
'sort_newest' => 'Newest',
],
'pagination' => [
'nav_label' => 'Pagination',
'page' => 'Page :page',
'next' => 'Next page',
'previous' => 'Previous page',
],
];
+16 -16
View File
@@ -10,14 +10,14 @@
<h1 class="font-display font-extrabold text-h1">{{ $collection->translateAttribute('name') }}</h1> <h1 class="font-display font-extrabold text-h1">{{ $collection->translateAttribute('name') }}</h1>
<x-breadcrumb :items="[ <x-breadcrumb :items="[
['label' => __('general.nav.home'), 'href' => route('home')], ['label' => __('storefront.nav.home'), 'href' => route('home')],
['label' => $collection->translateAttribute('name')], ['label' => $collection->translateAttribute('name')],
]" /> ]" />
</div> </div>
<div class="flex items-center justify-between gap-6 flex-wrap border-b border-black pb-6 mb-10"> <div class="flex items-center justify-between gap-6 flex-wrap border-b border-black pb-6 mb-10">
<p class="text-neutral-600"> <p class="text-neutral-600">
{{ trans_choice('general.shop.showing_results', $products->total(), [ {{ trans_choice('storefront.shop.showing_results', $products->total(), [
'first' => $products->firstItem() ?? 0, 'first' => $products->firstItem() ?? 0,
'last' => $products->lastItem() ?? 0, 'last' => $products->lastItem() ?? 0,
'total' => $products->total(), 'total' => $products->total(),
@@ -26,13 +26,13 @@
{{-- Dummy — not wired to real sorting yet --}} {{-- Dummy — not wired to real sorting yet --}}
<x-ui.select <x-ui.select
:ariaLabel="__('general.shop.sort_label')" :ariaLabel="__('storefront.shop.sort_label')"
:options="[ :options="[
['value' => 'default', 'label' => __('general.shop.sort_default')], ['value' => 'default', 'label' => __('storefront.shop.sort_default')],
['value' => 'popularity', 'label' => __('general.shop.sort_popularity')], ['value' => 'popularity', 'label' => __('storefront.shop.sort_popularity')],
['value' => 'price-asc', 'label' => __('general.shop.sort_price_asc')], ['value' => 'price-asc', 'label' => __('storefront.shop.sort_price_asc')],
['value' => 'price-desc', 'label' => __('general.shop.sort_price_desc')], ['value' => 'price-desc', 'label' => __('storefront.shop.sort_price_desc')],
['value' => 'newest', 'label' => __('general.shop.sort_newest')], ['value' => 'newest', 'label' => __('storefront.shop.sort_newest')],
]" ]"
value="default" value="default"
/> />
@@ -43,7 +43,7 @@
{{-- Products --}} {{-- Products --}}
<div> <div>
@if($products->isEmpty()) @if($products->isEmpty())
<p class="text-neutral-500">{{ __('general.shop.no_products') }}</p> <p class="text-neutral-500">{{ __('storefront.shop.no_products') }}</p>
@else @else
<x-product-grid :products="$products->items()" cols="3" /> <x-product-grid :products="$products->items()" cols="3" />
@@ -57,18 +57,18 @@
<aside class="flex flex-col gap-10"> <aside class="flex flex-col gap-10">
<div> <div>
<label for="shop-search" class="sr-only">{{ __('general.shop.search_label') }}</label> <label for="shop-search" class="sr-only">{{ __('storefront.shop.search_label') }}</label>
<div class="relative"> <div class="relative">
<x-ui.input <x-ui.input
type="search" type="search"
id="shop-search" id="shop-search"
:placeholder="__('general.shop.search_placeholder')" :placeholder="__('storefront.shop.search_placeholder')"
class="pr-10" class="pr-10"
/> />
<button <button
type="button" type="button"
class="absolute right-0 top-1/2 -translate-y-1/2" class="absolute right-0 top-1/2 -translate-y-1/2"
aria-label="{{ __('general.shop.search_label') }}" aria-label="{{ __('storefront.shop.search_label') }}"
> >
<x-ui.icon name="search" :size="20" /> <x-ui.icon name="search" :size="20" />
</button> </button>
@@ -76,7 +76,7 @@ class="absolute right-0 top-1/2 -translate-y-1/2"
</div> </div>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<h2 class="font-display font-extrabold uppercase">{{ __('general.shop.filter_price') }}</h2> <h2 class="font-display font-extrabold uppercase">{{ __('storefront.shop.filter_price') }}</h2>
<div class="flex items-center gap-2" aria-hidden="true"> <div class="flex items-center gap-2" aria-hidden="true">
<x-ui.icon name="arrow-left" :size="20" /> <x-ui.icon name="arrow-left" :size="20" />
@@ -87,15 +87,15 @@ class="absolute right-0 top-1/2 -translate-y-1/2"
<div class="flex items-center justify-between gap-4"> <div class="flex items-center justify-between gap-4">
<span class="text-sm">€10 - €50</span> <span class="text-sm">€10 - €50</span>
<button type="button" class="underline-slide [--slide-h:1px] font-display font-bold italic uppercase text-sm"> <button type="button" class="underline-slide [--slide-h:1px] font-display font-bold italic uppercase text-sm">
{{ __('general.shop.apply') }} {{ __('storefront.shop.apply') }}
</button> </button>
</div> </div>
</div> </div>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<h2 class="font-display font-extrabold uppercase">{{ __('general.shop.availability') }}</h2> <h2 class="font-display font-extrabold uppercase">{{ __('storefront.shop.availability') }}</h2>
<x-ui.checkbox id="shop-in-stock" name="in_stock"> <x-ui.checkbox id="shop-in-stock" name="in_stock">
{{ __('general.shop.in_stock_only') }} {{ __('storefront.shop.in_stock_only') }}
</x-ui.checkbox> </x-ui.checkbox>
</div> </div>
+2 -2
View File
@@ -12,7 +12,7 @@
{{-- Products (CSS-only hover dropdown) --}} {{-- Products (CSS-only hover dropdown) --}}
<div class="group relative h-full flex items-center"> <div class="group relative h-full flex items-center">
<a href="{{ url('/'.app()->getLocale().'/products') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline py-8"> <a href="{{ url('/'.app()->getLocale().'/products') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline py-8">
<span>{{ __('general.nav.products') }}</span> <span>{{ __('storefront.nav.products') }}</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-4 not-italic transition-transform group-hover:rotate-180"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-4 not-italic transition-transform group-hover:rotate-180">
<path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
</svg> </svg>
@@ -27,7 +27,7 @@
</div> </div>
{{-- Contact --}} {{-- Contact --}}
<a href="{{ route('contact') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('general.nav.contact') }}</span></a> <a href="{{ route('contact') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('storefront.nav.contact') }}</span></a>
</nav> </nav>
@@ -8,13 +8,13 @@ class="flex flex-col gap-8 mt-10"
@csrf @csrf
{{-- Rating --}} {{-- Rating --}}
<x-ui.field label="Βαθμολογία" for="rating" :required="true"> <x-ui.field :label="__('storefront.review.rating')" for="rating" :required="true">
<div <div
id="rating" id="rating"
data-controller="star-rating" data-controller="star-rating"
class="flex items-center gap-1.5 text-brand" class="flex items-center gap-1.5 text-brand"
role="radiogroup" role="radiogroup"
aria-label="Βαθμολογία" aria-label="{{ __('storefront.review.rating') }}"
aria-required="true" aria-required="true"
> >
<input type="hidden" name="rating" value="0" data-star-rating-target="input"> <input type="hidden" name="rating" value="0" data-star-rating-target="input">
@@ -24,7 +24,7 @@ class="flex items-center gap-1.5 text-brand"
data-star-rating-target="star" data-star-rating-target="star"
data-value="{{ $i }}" data-value="{{ $i }}"
data-action="click->star-rating#select mouseenter->star-rating#hover mouseleave->star-rating#leave" data-action="click->star-rating#select mouseenter->star-rating#hover mouseleave->star-rating#leave"
aria-label="{{ $i }} {{ $i === 1 ? 'αστέρι' : 'αστέρια' }}" aria-label="{{ trans_choice('storefront.review.stars_count', $i, ['count' => $i]) }}"
aria-pressed="false" aria-pressed="false"
> >
<svg <svg
@@ -43,24 +43,24 @@ class="w-6 h-6"
</div> </div>
</x-ui.field> </x-ui.field>
<x-ui.field label="Γράψε μια αξιολόγηση" for="review-content" :required="true"> <x-ui.field :label="__('storefront.review.write_label')" for="review-content" :required="true">
<x-ui.textarea id="review-content" name="content" :required="true" /> <x-ui.textarea id="review-content" name="content" :required="true" />
</x-ui.field> </x-ui.field>
<x-ui.field label="Όνομα" for="review-name" labelDescription="Προαιρετικό"> <x-ui.field :label="__('storefront.review.name')" for="review-name" :labelDescription="__('storefront.review.name_optional')">
<x-ui.input id="review-name" name="name" autocomplete="name" /> <x-ui.input id="review-name" name="name" autocomplete="name" />
</x-ui.field> </x-ui.field>
<x-ui.field label="Email" for="review-email" :required="true" labelDescription="Δεν θα δημοσιευτεί"> <x-ui.field :label="__('storefront.review.email')" for="review-email" :required="true" :labelDescription="__('storefront.review.email_not_published')">
<x-ui.input id="review-email" name="email" type="email" :required="true" autocomplete="email" /> <x-ui.input id="review-email" name="email" type="email" :required="true" autocomplete="email" />
</x-ui.field> </x-ui.field>
<x-ui.checkbox id="review-save-info" name="save_info" > <x-ui.checkbox id="review-save-info" name="save_info" >
<span class="text-sm">Αποθήκευσε το όνομα και το email μου για την επόμενη φορά που θα σχολιάσω.</span> <span class="text-sm">{{ __('storefront.review.save_info') }}</span>
</x-ui.checkbox> </x-ui.checkbox>
<div> <div>
<x-ui.button type="submit">Υποβολή</x-ui.button> <x-ui.button type="submit">{{ __('storefront.review.submit') }}</x-ui.button>
</div> </div>
</form> </form>
@@ -29,7 +29,7 @@ class="flex items-center gap-1.5 text-brand"
@if ($showCount && $count > 0) @if ($showCount && $count > 0)
<span class="text-sm text-neutral-500"> <span class="text-sm text-neutral-500">
({{ trans_choice('general.customer_reviews', $count, ['count' => $count]) }}) ({{ trans_choice('storefront.customer_reviews', $count, ['count' => $count]) }})
</span> </span>
@endif @endif
@@ -1,29 +1,32 @@
{{-- $variants: array of Modules\Core\Product\Services\ProductIndexer's mapVariant()
shape (id, options: [{option, value, meta}], ...) — plain arrays, not Eloquent
models, since this is fed from Modules\Core\Product\Services\ProductService. --}}
@props(['variants', 'option' => null]) @props(['variants', 'option' => null])
<div {{ $attributes }}> <div {{ $attributes }}>
@if($option) @if($option)
<p class="font-bold mb-3 text-sm uppercase tracking-wide"> <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> </p>
@endif @endif
<div <div
class="flex flex-wrap gap-2" class="flex flex-wrap gap-2"
role="group" role="group"
aria-label="{{ $option?->translate('name') ?? 'Color' }}" aria-label="{{ $option ?? 'Color' }}"
> >
@foreach($variants as $variant) @foreach($variants as $variant)
@php @php
$value = $variant->values->first(); $value = $variant['options'][0] ?? null;
$label = $value?->translate('name') ?? ''; $label = $value['value'] ?? '';
$bg = $value?->meta['hex'] ?? '#cccccc'; $bg = $value['meta']['hex'] ?? '#cccccc';
@endphp @endphp
<button <button
type="button" type="button"
class="color-swatch" class="color-swatch"
data-product-form-target="swatch" data-product-form-target="swatch"
data-action="click->product-form#selectVariant" data-action="click->product-form#selectVariant"
data-variant-id="{{ $variant->id }}" data-variant-id="{{ $variant['id'] }}"
style="background-color: {{ $bg }};" style="background-color: {{ $bg }};"
aria-label="{{ $label }}" aria-label="{{ $label }}"
aria-pressed="false" aria-pressed="false"
@@ -9,21 +9,21 @@
--}} --}}
@if($paginator->hasPages()) @if($paginator->hasPages())
<nav aria-label="{{ __('general.pagination.nav_label') }}" {{ $attributes->merge(['class' => 'flex items-center gap-6 font-display font-bold']) }}> <nav aria-label="{{ __('storefront.pagination.nav_label') }}" {{ $attributes->merge(['class' => 'flex items-center gap-6 font-display font-bold']) }}>
<ol class="flex items-center gap-6"> <ol class="flex items-center gap-6">
@foreach($paginator->getUrlRange(1, $paginator->lastPage()) as $page => $url) @foreach($paginator->getUrlRange(1, $paginator->lastPage()) as $page => $url)
<li> <li>
@if($page === $paginator->currentPage()) @if($page === $paginator->currentPage())
<span class="underline-slide is-active" aria-current="page">{{ str_pad((string) $page, 2, '0', STR_PAD_LEFT) }}</span> <span class="underline-slide is-active" aria-current="page">{{ str_pad((string) $page, 2, '0', STR_PAD_LEFT) }}</span>
@else @else
<a href="{{ $url }}" class="underline-slide" aria-label="{{ __('general.pagination.page', ['page' => $page]) }}">{{ str_pad((string) $page, 2, '0', STR_PAD_LEFT) }}</a> <a href="{{ $url }}" class="underline-slide" aria-label="{{ __('storefront.pagination.page', ['page' => $page]) }}">{{ str_pad((string) $page, 2, '0', STR_PAD_LEFT) }}</a>
@endif @endif
</li> </li>
@endforeach @endforeach
</ol> </ol>
@if($paginator->hasMorePages()) @if($paginator->hasMorePages())
<a href="{{ $paginator->nextPageUrl() }}" aria-label="{{ __('general.pagination.next') }}"> <a href="{{ $paginator->nextPageUrl() }}" aria-label="{{ __('storefront.pagination.next') }}">
<x-ui.icon name="arrow-right" :size="24" /> <x-ui.icon name="arrow-right" :size="24" />
</a> </a>
@endif @endif
@@ -17,13 +17,13 @@ class="w-full h-auto block"
> >
@else @else
<div class="w-full aspect-square bg-neutral-300 flex items-center justify-center text-neutral-500 text-sm"> <div class="w-full aspect-square bg-neutral-300 flex items-center justify-center text-neutral-500 text-sm">
Χωρίς εικόνα {{ __('storefront.product.no_image') }}
</div> </div>
@endif @endif
</a> </a>
<x-ui.button size="md" position="absolute" class="opacity-0 group-hover:opacity-100 transition-opacity duration-100"> <x-ui.button size="md" position="absolute" class="opacity-0 group-hover:opacity-100 transition-opacity duration-100">
Προσθήκη στο καλάθι {{ __('storefront.product.add_to_cart') }}
</x-ui.button> </x-ui.button>
</div> </div>
+1 -1
View File
@@ -1,6 +1,6 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', __('general.nav.contact')) @section('title', __('storefront.nav.contact'))
@section('description', 'Επικοινώνησε μαζί μας για οποιαδήποτε απορία ή ιδέα έχεις και θα σου απαντήσουμε το συντομότερο δυνατό.') @section('description', 'Επικοινώνησε μαζί μας για οποιαδήποτε απορία ή ιδέα έχεις και θα σου απαντήσουμε το συντομότερο δυνατό.')
@section('content') @section('content')
+2 -2
View File
@@ -56,12 +56,12 @@ class="{{ $loop->first ? '' : 'hidden' }} group h-full flex flex-col justify-cen
class="w-full h-full object-cover" class="w-full h-full object-cover"
> >
@else @else
<span class="text-neutral-500 text-sm">Χωρίς εικόνα</span> <span class="text-neutral-500 text-sm">{{ __('storefront.product.no_image') }}</span>
@endif @endif
</a> </a>
<x-ui.button size="md" position="absolute" class="opacity-0 group-hover:opacity-100 transition-opacity duration-100"> <x-ui.button size="md" position="absolute" class="opacity-0 group-hover:opacity-100 transition-opacity duration-100">
Προσθήκη στο καλάθι {{ __('storefront.product.add_to_cart') }}
</x-ui.button> </x-ui.button>
</div> </div>
+37 -36
View File
@@ -1,18 +1,16 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', $product->translateAttribute('name') . ' — ' . config('app.name')) @section('title', $product['name'] . ' — ' . config('app.name'))
@section('description', $product->translateAttribute('description')) @section('description', $product['description'])
@section('content') @section('content')
<div class="max-w-7xl mx-auto px-4 sm:px-8 py-12"> <div class="max-w-7xl mx-auto px-4 sm:px-8 py-12">
@php $collection = $product->collections->first(); @endphp
<x-breadcrumb class="mb-14 justify-end" :items="[ <x-breadcrumb class="mb-14 justify-end" :items="[
$collection $collection
? ['label' => $collection->translateAttribute('name'), 'href' => route('category.show', ['collection' => $collection])] ? ['label' => $collection->translateAttribute('name'), 'href' => route('category.show', ['collection' => $collection])]
: ['label' => __('general.nav.products'), 'href' => '/products'], : ['label' => __('storefront.nav.products'), 'href' => '/products'],
['label' => $product->translateAttribute('name')], ['label' => $product['name']],
]" /> ]" />
<div <div
@@ -26,7 +24,7 @@ class="grid grid-cols-1 md:grid-cols-2 gap-12"
data-controller="product-gallery" data-controller="product-gallery"
class="flex gap-4 items-start" class="flex gap-4 items-start"
> >
@if($product->media->isNotEmpty()) @if(!empty($product['media']))
{{-- Thumbnails --}} {{-- Thumbnails --}}
<div class="flex flex-col items-center gap-1 w-[116px] shrink-0 -mt-12.5"> <div class="flex flex-col items-center gap-1 w-[116px] shrink-0 -mt-12.5">
<button <button
@@ -41,20 +39,20 @@ class="gallery-arrow w-full flex items-center justify-center py-2"
class="flex flex-col gap-4 overflow-hidden" class="flex flex-col gap-4 overflow-hidden"
style="max-height: var(--gallery-height, 600px)" style="max-height: var(--gallery-height, 600px)"
> >
@foreach($product->media as $i => $media) @foreach($product['media'] as $i => $media)
<button <button
type="button" type="button"
data-action="click->product-gallery#select" data-action="click->product-gallery#select"
data-product-gallery-target="thumb" data-product-gallery-target="thumb"
data-src="{{ $media->getUrl() }}" data-src="{{ $media['url'] }}"
data-alt="{{ $product->translateAttribute('name') }}" data-alt="{{ $product['name'] }}"
class="block w-full shrink-0 border border-black overflow-hidden " class="block w-full shrink-0 border border-black overflow-hidden "
aria-label="View image {{ $i + 1 }}" aria-label="View image {{ $i + 1 }}"
aria-pressed="{{ $i === 0 ? 'true' : 'false' }}" aria-pressed="{{ $i === 0 ? 'true' : 'false' }}"
> >
<!-- opacity-50 transition-opacity {{ $i === 0 ? 'opacity-100' : '' }}" --> <!-- opacity-50 transition-opacity {{ $i === 0 ? 'opacity-100' : '' }}" -->
<img src="{{ $media->getUrl() }}" alt="" class="w-full h-auto object-cover" aria-hidden="true"> <img src="{{ $media['url'] }}" alt="" class="w-full h-auto object-cover" aria-hidden="true">
</button> </button>
@endforeach @endforeach
</div> </div>
@@ -77,8 +75,8 @@ class="flex-1 border border-black bg-white cursor-zoom-in block p-0"
<img <img
data-product-form-target="image" data-product-form-target="image"
data-product-gallery-target="main" data-product-gallery-target="main"
src="{{ $product->media->first()->getUrl() }}" src="{{ $product['media'][0]['url'] }}"
alt="{{ $product->translateAttribute('name') }}" alt="{{ $product['name'] }}"
class="w-full h-auto block" class="w-full h-auto block"
> >
</button> </button>
@@ -136,7 +134,7 @@ class="absolute bottom-6 right-8 text-white text-sm"
</div> </div>
@else @else
<div class="w-full bg-neutral-300 flex items-center justify-center text-neutral-500 min-h-64"> <div class="w-full bg-neutral-300 flex items-center justify-center text-neutral-500 min-h-64">
No image {{ __('storefront.product.no_image') }}
</div> </div>
@endif @endif
</div> </div>
@@ -145,36 +143,36 @@ class="absolute bottom-6 right-8 text-white text-sm"
<div class="flex flex-col gap-6"> <div class="flex flex-col gap-6">
<h1 class="font-display font-medium text-4xl lg:text-[54px]"> <h1 class="font-display font-medium text-4xl lg:text-[54px]">
{{ $product->translateAttribute('name') }} {{ $product['name'] }}
</h1> </h1>
<x-reviews-stars :rating="3" :count="24" :showCount="true" /> <x-reviews-stars :rating="$product['average_rating'] ?? 0" :count="$product['review_count']" :showCount="true" />
@if($product->variants->first()?->prices->isNotEmpty()) @if($product['price'] !== null)
<p class="text-2xl font-bold" data-product-form-target="price"> <p class="text-2xl font-bold" data-product-form-target="price">
<x-ui.price :amount="$product->variants->first()->prices->first()->price->decimal" /> <x-ui.price :amount="$product['price']" />
</p> </p>
@endif @endif
@php @php
$desc = strip_tags($product->translateAttribute('description') ?? ''); $desc = strip_tags($product['description'] ?? '');
$descTruncated = Str::limit($desc, 137); $descTruncated = Str::limit($desc, 137);
$descNeedsMore = mb_strlen($desc) > mb_strlen(rtrim($descTruncated, '.')); $descNeedsMore = mb_strlen($desc) > mb_strlen(rtrim($descTruncated, '.'));
@endphp @endphp
<div class="text-base leading-relaxed"> <div class="text-base leading-relaxed">
{{ $descTruncated }} {{ $descTruncated }}
@if($descNeedsMore) @if($descNeedsMore)
<a href="#tab-panel-description" class="underline-slide font-semibold whitespace-nowrap">Περισσότερα</a> <a href="#tab-panel-description" class="underline-slide font-semibold whitespace-nowrap">{{ __('storefront.product.read_more') }}</a>
@endif @endif
</div> </div>
@if($option && $product->variants->count() >= 1) @if($option && !empty($product['variants']))
<x-ui.color-swatch :variants="$product->variants" :option="$option" /> <x-ui.color-swatch :variants="$product['variants']" :option="$option" />
@endif @endif
<div class="flex items-stretch gap-10"> <div class="flex items-stretch gap-10">
<x-ui.quantity name="quantity" /> <x-ui.quantity name="quantity" />
<x-ui.button class="flex-1">Προσθήκη στο καλάθι</x-ui.button> <x-ui.button class="flex-1">{{ __('storefront.product.add_to_cart') }}</x-ui.button>
</div> </div>
</div> </div>
@@ -182,17 +180,13 @@ class="absolute bottom-6 right-8 text-white text-sm"
</div> </div>
<x-ui.tabs class="mt-16" size="lg" :tabs="[ <x-ui.tabs class="mt-16" size="lg" :tabs="[
['id' => 'description', 'label' => __('general.product.description')], ['id' => 'description', 'label' => __('storefront.product.description')],
// ['id' => 'reviews', 'label' => __('general.product.reviews') . ' (' . count($reviews) . ')'], ['id' => 'reviews', 'label' => __('storefront.product.reviews') . ' (' . $product['review_count'] . ')'],
['id' => 'reviews', 'label' => __('general.product.reviews') . ' (3)'],
]"> ]">
<x-slot name="description"> <x-slot name="description">
<div class="leading-7 [&_p]:mt-4"> <div class="leading-7 [&_p]:mt-4">
{!! $product->translateAttribute('description') !!} {!! $product['description'] !!}
</div> </div>
@if($product->translateAttribute('details'))
<div class="mt-6">{!! $product->translateAttribute('details') !!}</div>
@endif
<ul class="mt-8 flex flex-col gap-3 text-neutral-600 list-disc list-outside pl-5"> <ul class="mt-8 flex flex-col gap-3 text-neutral-600 list-disc list-outside pl-5">
<li>Όλα τα προϊόντα εκτυπώνονται και προετοιμάζονται κατά παραγγελία. Ο χρόνος προετοιμασίας κυμαίνεται μεταξύ 2 και 7 εργάσιμων ημερών.</li> <li>Όλα τα προϊόντα εκτυπώνονται και προετοιμάζονται κατά παραγγελία. Ο χρόνος προετοιμασίας κυμαίνεται μεταξύ 2 και 7 εργάσιμων ημερών.</li>
<li>Όλα τα προϊόντα κατασκευάζονται με τρισδιάστατη εκτύπωση σε ειδικούς εκτυπωτές πλαστικού υλικού. Πιθανώς να έχουν εμφανείς γραμμές ένωσης, στρώσεις εκτύπωσης υλικού και μικρές ατέλειες. Είναι φυσιολογικό για το αποτέλεσμα αυτής της δημιουργικής διαδικασίας.</li> <li>Όλα τα προϊόντα κατασκευάζονται με τρισδιάστατη εκτύπωση σε ειδικούς εκτυπωτές πλαστικού υλικού. Πιθανώς να έχουν εμφανείς γραμμές ένωσης, στρώσεις εκτύπωσης υλικού και μικρές ατέλειες. Είναι φυσιολογικό για το αποτέλεσμα αυτής της δημιουργικής διαδικασίας.</li>
@@ -200,19 +194,26 @@ class="absolute bottom-6 right-8 text-white text-sm"
</ul> </ul>
</x-slot> </x-slot>
<x-slot name="reviews"> <x-slot name="reviews">
{{-- @if(count($reviews) > 0) @if(!empty($product['reviews']))
<div class="mb-10"> <div class="mb-10">
@foreach($reviews as $review) @foreach($product['reviews'] as $review)
<x-review-card :review="$review" /> <x-review-card :review="[
'rating' => $review['rating'],
'name' => $review['reviewer_name'],
'date' => $review['reviewed_at'] ? \Illuminate\Support\Carbon::createFromTimestamp($review['reviewed_at'])->translatedFormat('d M Y') : '',
'text' => $review['body'],
'image' => $review['media'][0]['url'] ?? null,
]" />
@endforeach @endforeach
</div> </div>
@else @else
<p class="text-neutral-500 mb-10">Δεν υπάρχουν αξιολογήσεις ακόμα.</p> <p class="text-neutral-500 mb-10">{{ __('storefront.review.no_reviews_yet') }}</p>
@endif @endif
<h3 class="text-h4 font-bold"> <h3 class="text-h4 font-bold">
{{ count($reviews) > 0 ? 'Πρόσθεσε μια' : 'Γράψε την πρώτη' }} αξιολόγηση για το «{{ $product->translateAttribute('name') }}» {{ $product['review_count'] > 0 ? __('storefront.review.write_new') : __('storefront.review.write_first') }}
</h3> --}} {{ __('storefront.review.for_product', ['name' => $product['name']]) }}
</h3>
<x-review-form :product="$product" /> <x-review-form :product="$product" />
</x-slot> </x-slot>
+1 -1
View File
@@ -12,7 +12,7 @@
->group(function () { ->group(function () {
Route::get('/', [HomeController::class, 'index'])->name('home'); Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/products/{product}', [ProductController::class, 'show'])->name( Route::get('/products/{id}', [ProductController::class, 'show'])->name(
'product.show', 'product.show',
); );