Add new data in getBasket context
This commit is contained in:
@@ -12,11 +12,10 @@ use App\Repositories\Shop\Orders;
|
|||||||
|
|
||||||
class BasketController extends Controller
|
class BasketController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function getPrice(Request $request)
|
public function getPrice(Request $request)
|
||||||
{
|
{
|
||||||
$offer_id = $request->input('offer_id');
|
$offer_id = $request->input('offer_id');
|
||||||
$quantity = $request->input('quantity');
|
$quantity = $request->input('quantity') ?? 1;
|
||||||
$price = Offers::getPrice($offer_id, $quantity)->price_taxed;
|
$price = Offers::getPrice($offer_id, $quantity)->price_taxed;
|
||||||
return number_format($quantity * $price, 2);
|
return number_format($quantity * $price, 2);
|
||||||
}
|
}
|
||||||
@@ -24,12 +23,11 @@ class BasketController extends Controller
|
|||||||
public function addBasket(Request $request)
|
public function addBasket(Request $request)
|
||||||
{
|
{
|
||||||
$offer_id = $request->input('offer_id');
|
$offer_id = $request->input('offer_id');
|
||||||
$quantity = $request->input('quantity');
|
$quantity = $request->input('quantity') ?? 1;
|
||||||
$update = $request->input('update') ?? false;
|
$update = $request->input('update') ?? false;
|
||||||
return Offers::addBasket($offer_id, $quantity, $update);
|
return Offers::addBasket($offer_id, $quantity, $update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function modalBasket($offer_id, $quantity)
|
public function modalBasket($offer_id, $quantity)
|
||||||
{
|
{
|
||||||
$data['offer'] = Offers::getFull($offer_id)->toArray();
|
$data['offer'] = Offers::getFull($offer_id)->toArray();
|
||||||
@@ -41,6 +39,8 @@ class BasketController extends Controller
|
|||||||
{
|
{
|
||||||
$data = self::init();
|
$data = self::init();
|
||||||
$data['basket'] = Offers::getBasket();
|
$data['basket'] = Offers::getBasket();
|
||||||
|
dump($data['basket']);
|
||||||
|
exit;
|
||||||
return view('Shop.Baskets.basket', $data);
|
return view('Shop.Baskets.basket', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||||
use App\Traits\Model\HasComments;
|
use App\Traits\Model\HasComments;
|
||||||
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
|
|
||||||
class Offer extends Model
|
class Offer extends Model
|
||||||
{
|
{
|
||||||
use BelongsToThrough, HasComments;
|
use BelongsToThrough, HasComments, HasRelationships;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
protected $table = 'shop_offers';
|
protected $table = 'shop_offers';
|
||||||
@@ -27,6 +28,26 @@ class Offer extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function categories()
|
||||||
|
{
|
||||||
|
return $this->article->categories();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function price_lists()
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function price_list_values()
|
||||||
|
{
|
||||||
|
return $this->hasManyDeep(
|
||||||
|
PriceListValue::class,
|
||||||
|
[Tariff::class, PriceList::class],
|
||||||
|
['id', 'tariff_id', 'price_list_id'],
|
||||||
|
['tariff_id', 'id', 'id'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function tariff()
|
public function tariff()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Tariff::class);
|
return $this->belongsTo(Tariff::class);
|
||||||
@@ -37,16 +58,6 @@ class Offer extends Model
|
|||||||
return $this->belongsTo(Variation::class);
|
return $this->belongsTo(Variation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function price_lists()
|
|
||||||
{
|
|
||||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function categories()
|
|
||||||
{
|
|
||||||
return $this->article->categories();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tags()
|
public function tags()
|
||||||
{
|
{
|
||||||
return $this->article->tags();
|
return $this->article->tags();
|
||||||
|
|||||||
@@ -47,10 +47,16 @@ class Offers
|
|||||||
{
|
{
|
||||||
$basket = ShopCart::getContent();
|
$basket = ShopCart::getContent();
|
||||||
// dump($basket->toArray());
|
// dump($basket->toArray());
|
||||||
$offers = Offer::with(['variation', 'article.article_nature', 'article.image'])->whereIn('id', ShopCart::keys())->get();
|
$offers = Offer::with([
|
||||||
|
'variation',
|
||||||
|
'article.article_nature',
|
||||||
|
'article.product.Specie',
|
||||||
|
'article.image',
|
||||||
|
])->whereIn('id', ShopCart::keys())->get();
|
||||||
foreach ($basket as $item) {
|
foreach ($basket as $item) {
|
||||||
$offer = $offers->where('id', $item->id)->first();
|
$offer = $offers->where('id', $item->id)->first();
|
||||||
|
dump($offer->toArray());
|
||||||
|
exit;
|
||||||
$article_nature = strtolower($offer->article->article_nature->name);
|
$article_nature = strtolower($offer->article->article_nature->name);
|
||||||
$data[$article_nature][] = [
|
$data[$article_nature][] = [
|
||||||
'id' => (int) $item->id,
|
'id' => (int) $item->id,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
@foreach ($basket as $nature => $items)
|
@foreach ($basket as $nature => $items)
|
||||||
<div class="row ml-1 mb-3 p-2 bg-green-light border">
|
<div class="row ml-1 mb-3 p-2 bg-green-light border">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2 style="font-size: 1.6em;">{{ ucfirst($nature) }}</h2>
|
<h2 style="font-size: 1.6em;" class="text-uppercase">{{ $nature }}</h2>
|
||||||
@foreach ($items as $item)
|
@foreach ($items as $item)
|
||||||
@include('Shop.Baskets.partials.article')
|
@include('Shop.Baskets.partials.article')
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-6 text-uppercase">
|
<div class="col-6 text-uppercase">
|
||||||
Tarif appliqué
|
Tarif appliqué
|
||||||
|
<span id="basket_sale_channel"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{ $sale_channel['name'] ?? '' }}
|
{{ $sale_channel['name'] ?? '' }}
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span id="basket-count"></span> ARTICLES
|
<span id="basket-count"></span> ARTICLES
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 text-right">
|
<div class="col-6 text-right font-weight-bold">
|
||||||
<span id="basket-total"></span> €
|
<span id="basket-total"></span> €
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,12 +50,12 @@
|
|||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
LIVRAISON
|
LIVRAISON
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 text-right">
|
<div class="col-6 text-right font-weight-bold">
|
||||||
<span id="shipping">5</span> €
|
<span id="shipping">5</span> €
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row m-3" style="font-size: 1.6em; font-weight: 600;">
|
<div class="row m-3 font-weight-bold" style="font-size: 1.6em;">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
TOTAL TTC
|
TOTAL TTC
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<div class="row basket-row" id="basket_offer-{{ $item['id'] }}" data-id={{ $item['id'] }}>
|
<div class="row basket-row" id="basket_offer-{{ $item['id'] }}" data-id={{ $item['id'] }}>
|
||||||
<div class="col-2 text-center">
|
<div class="col-2 text-center">
|
||||||
<img src="{{ $item['image'] }}" class="img-fluid">
|
<img src="{{ $item['image'] }}" class="img-fluid border border-success">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h3 style="font-size: 1.4em;">{{ $item['name'] }}</h3>
|
<h3 style="font-size: 1.4em;">{{ $item['name'] }}</h3>
|
||||||
|
<h4>{{ $item['article']['product']['specie']['latin'] }}</h4>
|
||||||
{{ $item['variation'] }}<br/>
|
{{ $item['variation'] }}<br/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user