I need to create an if condition, the function would be to hide or show products depending on whether it is visible or not
visible: 1 hidden: 0
The table is already created, as you can see, I only need the code
my code: blade.php
<div style="margin-top: 10px; " class="w-100">
@if(count($products)>0)
@php
$total = 0;
@endphp
@foreach($products as $product)
@php
$cart = \Session::get('cart');
$product_q = 0;
if ($cart) {
foreach ($cart as $item) {
if ($item->id == $product->id) {
$product_q = $item->quantity ?? 0;
$total = $total + ($product->price * $item->quantity);
}
}
}
if (is_numeric($product_q) == false) {
$product_q = 0;
}
@endphp
<div class="bg-dark tx-white h-100">
<ul class="list-group bordecero">
<li class="list-group-item bordecero bg-dark tx-white w-100">
<div class="col-12 p-0 d-flex justify-content-center align-items-center">
@if($category->show_img)
<div class="col-4">
@if(!empty($product->image))
<img style="height: auto;" class="w-100 shadow-sm bd img-fluid" src="">
@else
<img style="height: auto;" class="w-100 shadow-sm bd img-fluid" src="http://placehold.it/700x400">
@endif
</div>
@endif
<div class="@if($category->show_img) col-8 @else col-12 @endif">
<h5> <a style="color: #fff;" href=""></a><span class="badge badge-pill badge-light tx-dark ml-2 product-count-"></span>
</h5>
<h6>
<span style="color: #fff;" class="label label-success">$</span>
</h6>
<p style="color: #fff;"></p>
@if($product->destacado)
<span class="badge badge-pill badge-danger ">DESTACADO</span>
@endif
@php
$extras = App\Extra::where("product_id", $product->id)->first();
@endphp
@if(!empty($extras))
<a style="color: #2c2c2c;" href="">
<span class="badge badge-pill badge-primary mb-4 ">+ AGREGADOS</span>
</a>
@else
<span class="badge badge-pill badge-primary mb-4">SIN AGREGADOS</span>
@endif
<div class="col-12 p-0 d-flex">
<input type="hidden" id="quantity-" data-slug="" data-id="" class="form-control select2 quantity" name="num_entregable" @if(isset($product_q)) value="" @else value="1" @endif min="1" required>
<button class="btn btn-danger mr-2 quantity-modify" data-quantity="quantity-" data-modify="add"> <b><i class="fas fa-plus"></i></b></button>
<button class="btn btn-danger quantity-modify" data-quantity="quantity-" data-modify="remove"> <b><i class="fas fa-minus"></i></b></button>
</div>
</div>
</div>
</li>
</ul>
</div>
@endforeach
<div style="z-index: 100;" class="pedidob mg-t-auto">
<a class="btn btn-danger btn-rounded btn-block tx-white d-flex justify-content-center" href=""><b>VER PEDIDO - <span class="total"></span>$</b></a>
</div>
</div>
@else
<div class="col-lg-12">
<div class="card h-100">
<div class="card-body">
<h4 class="card-title">
<a href="#">No hay productos</a>
</h4>
</div>
</div>
</div>
@endif
I need to create an if condition to show or hide the products according to the 'visible' table
help pls
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire