I have a page in my project where I display single image that I get after getting the dynamic URL .I want now to add and to display several images related to same product . It's important to mention that in MySQL I defined the URL column as unique. My question is what is the best way to display several pictures on that page?
My route:
Route::get('shop/{category_url}/{product_url}', 'ShopController@item');
My Controller:
public function item($category_url, $product_url){
Product::getItem($product_url, self::$data);
return view('content.item', self::$data);
}
My model:
static public function getItem($product_url, &$data) {
$data['item'] = [];
if ($product = Product::where('url', '=', $product_url)->first()) {
$product = $product->toArray();
$data['item'] = $product;
$data['title'] .= '|' . $product['title'];
}
}
My view:
@extends ('master')
@section('content')
<div class="row">
<div class="col-md-12 text-center">
@if('item')
<h1 style="font-weight: bold; "></h1> <br>
<p><img width="500" src=""> </p> <br>
<p style="font-size:18px;">{!! $item['article'] !!}</p>
<p style="font-size:18px;"><b>Price on site:</b>$</p>
<p>
@if(Cart::get($item['id']))
<input disabled="disabled" type="button" value="In Cart!" class="btn btn-success" style="font-size:18px;">
@else
<input data-id="" type="button" value="+ Add to cart" class="btn btn-success add-to-cart" style="font-size:18px;">
@endif
<a href="" class="btn btn-primary" style="font-size:18px;">Checkout</a>
</p>
@else
<p class="text-center" style="font-size: 18px">No product details ...</p>
@endif
@endsection
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire