namespace App\Models;
+use Cubist\Backpack\app\Magic\Menu\Menu;
use Cubist\Backpack\app\Magic\Models\CubistMagicPageModel;
use Cubist\Util\Json;
use Illuminate\Support\Facades\App;
}
+ /**
+ * Custom accessor to return URL to product detail
+ * page by accessing $product->URL...
+ */
+ public function getURLAttribute()
+ {
+ return Menu::getNavigation()->getHrefById("product/{$this->id}");
+ }
+
/**
* Custom accessor to return fallback image
* by accessing $product->image_fallback...
'category' => $product->type->name,
'quantity' => $cart_items[$product->id],
'image' => $product->image,
+ 'URL' => $product->url,
];
}
<template>
<div class="cart-item flex mb-1v">
- <div class="border-gray-100 border-2 bg-center bg-contain bg-no-repeat flex-shrink-0"
- :style="`background-image: url(${item.image}); width: 144px; height: 144px`">
- </div>
+ <a class="block border-gray-100 border-2 bg-center bg-contain bg-no-repeat flex-shrink-0"
+ :href="item.URL"
+ :style="`background-image: url(${item.image}); width: 144px; height: 144px`">
+ </a>
<div class="pl-6 leading-relaxed flex-grow">
- <div class="font-bold">
+ <a :href="item.URL" class="block text-navy font-display">
{{ item.category }}
<br>
{{ item.name }}
- </div>
+ </a>
<div class="cart-quantity bg-grey-100 py-1 pl-3 my-2 flex items-center justify-between">
<span class="mr-2">Quantité</span>
<number-input :value="item.quantity" :min="1" inline center controls @change="updateQuantity"></number-input>
<content class="pb-3v">
<text-block :title="$page->page_heading" />
- {{-- Columns set to auto because cart will disappear when quote form is sent, leaving just the confirmation message. --}}
- <grid cols="auto">
+ <div v-if="cartItemCount > 0">
- {{-- Nested divs to allow grey backgrounds of columns to match the height of their content instead of total height --}}
- <div v-if="cartItemCount > 0">
- <cart :items='items' class="cart-page bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
- </div>
+ {{-- Columns set to auto because cart will disappear when quote form is sent, leaving just the confirmation message. --}}
+ <grid cols="auto">
- <div>
- <div class="bg-grey-100 p-1v">
- @form([
+ {{-- Nested divs to allow grey backgrounds of columns to match the height of their content instead of total height --}}
+ <div>
+ <cart :items='items' class="cart-page bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
+ </div>
+
+ <div>
+ <div class="bg-grey-100 p-1v">
+ @form([
'action' => '/ajax/request_quote',
'extra_fields' => '<input type="hidden" name="cart_data" :value="cartData">' // Populated by VueJS
- ])
+ ])
+ </div>
</div>
- </div>
- </grid>
+ </grid>
+
+ </div>
+
+ <div v-if="cartItemCount == 0" class="p-1v text-center bg-grey-100 text-lg">
+ {{ __("Vous n'avez encore rien sélectionné") }}
+ </div>
</content>
-@php
- $product_URL = $nav->getHrefById("product/{$product->id}");
-@endphp
<div data-product-id="{{$id}}" class="product-grid-item bg-grey-200">
{{-- Image holder --}}
- <a href="{{ $product_URL }}">
+ <a href="{{ $product->URL }}">
<div class="product-img-holder">
<div class="product-img"
style="background-image: url({{ $product->getEntity()->image }})"></div>
{{-- Product details --}}
<div class="p-4">
- <h3><a class="text-navy" href="{{ $product_URL }}">{{ $product->get('reference') }}</a>
+ <h3><a class="text-navy" href="{{ $product->URL }}">{{ $product->get('reference') }}</a>
</h3>
<div class="product-highlights text-sm">
{{$product->get('name')}}
</div>
<p class="mt-4">
- <a href="{{ $product_URL }}">
+ <a href="{{ $product->URL }}">
{{ __('Voir la fiche produit') }}
</a>
</p>