How to show data in modal of a specific id in laravel? - php

I have all my products in view:welcome.blade.php and The problem is how can I show modal with the details of a specific id?
<!-- End Product MEnu -->
<div class="row product__list">
#foreach($products as $product)
<!-- Start Single Product -->
<div class="col-md-3 single__pro col-lg-3 col-md-4 cat--1 col-sm-12">
<div class="product foo">
<div class="product__inner">
<div class="pro__thumb">
<a href="#">
<img src="{{ asset('storage/products/' . $product->image ) }}" width="270px" height="270px" alt="product images">
</a>
</div>
<div class="product__hover__info">
<ul class="product__action">
<li><a id="{{ $product->id }}" data-toggle="modal" data-target="#productModal" title="Quick View" class="quick-view modal-view detail-link viewDetails" href="#"><span class="ti-plus"></span></a></li>
<li><a title="Add TO Cart" href="cart.html"><span class="ti-shopping-cart"></span></a></li>
</ul>
</div>
<div class="add__to__wishlist">
<a data-toggle="tooltip" title="Add To Wishlist" class="add-to-cart" href="wishlist.html"><span class="ti-heart"></span></a>
</div>
</div>
<div class="product__details">
<h2>{{ $product->name }}</h2>
<ul class="product__price">
{{-- <li class="old__price">$16.00</li> --}}
<li class="new__price">₹ {{ $product->price }}</li>
</ul>
</div>
</div>
</div>
<!-- End Single Product -->
#endforeach
How can i show the details of a product in a modal?

Please Change Your data-target="#productModal{{ $product->id }}"
<div class="product__hover__info">
<ul class="product__action">
<li><span class="ti-plus"></span></li>
<li><a title="Add TO Cart" href="cart.html"><span class="ti-shopping-cart"></span></a></li>
</ul>
</div>
<div class="modal fade" id="productModal{{ $product->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
{{$product->id}}
</div>
</div>
</div>
</div>

Related

Grouping items under accordian header in laravel

I have an array of items that I'm using in Laravel (in the array, half are "parent items" and half are "child Items")
Say the array is 30 items, 15 of each type, I'm trying to get a result where I would have a single accordian header that says "Parent items" with the 15 parent items under the single header, then a single accordian header for the "Child items" with those 15 under it.
However, with my current code I'm getting the header over each individual item.
I understand this is because of the foreach, but I'm stumped on how exactly to achieve what I'm looking for and I just can't seem to get around the issue of the header over each item
What am I doing wrong here?
#foreach($items as $item)
#if($item['type'] == "Parent Item")
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Main/Parent Items
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body">
{{$item['Description']}}
</div>
</div>
</div>
</div>
#elseif($item['type'] == "Child Item")
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Sub/Child Items
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
{{$item['Description']}}
</div>
</div>
</div>
</div>
#endif
#endforeach
You'll just need to do 2 loops, ie:
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Main/Parent Items
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
#foreach($items as $item)
#if($item['type'] == "Parent Item")
<div class="card-body">
{{$item['Description']}}
</div>
#endif
#endforeach
</div>
</div>
</div>
<div class="accordion" id="accordionExample2">
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Sub/Child Items
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample2">
#foreach($items as $item)
#if($item['type'] == "Child Item")
<div class="card-body">
{{$item['Description']}}
</div>
#endif
#endforeach
</div>
</div>
</div>
As a side note that id="accordionExample" on both elements is invalid, those should have unique ids.

How do I dynamically populate modal from PHP server side product data?

I am retrieving some products from the database using PHP and MySQL. I am displaying these products in a carousel. When the user hovers, a "Show Quick Details" button will appear.
When the user clicks that button, a modal shows up displaying the product details.
Example:
Here is the modal when the user clicks.... (no, the products don't match right now, I am using a template the client gave me with example images ).
User Clicks Button:
My question is, how do I go about populating the modal with the correct product information? Do I have to create 10 modals dynamically in my PHP , or is there a better route? I am kinda stumped on how to approach this.
Here is the modal I am using, in case that is helpful for an answer:
<!--====== Quick View Part Start ======-->
<!-- Modal -->
<div class="modal fade " id="productQuickModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<i class="fal fa-times"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="product-quick-view-image mt-30">
<div class="quick-view-image">
<div class="single-view-image">
<img src="images/product-17.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-18.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-19.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-20.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-21.jpg" alt="product">
</div>
</div>
<ul class="quick-view-thumb">
<li>
<div class="single-thumb">
<img src="images/product-17.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-18.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-19.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-20.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-21.jpg" alt="">
</div>
</li>
</ul>
</div> <!-- Modal Quick View Image -->
</div>
<div class="col-md-6">
<div class="product-quick-view-content mt-30">
<h3 class="product-title">Trans-Weight Hooded Wind and Water Resistant Shell</h3>
<p class="reference">Reference: demo_12</p>
<ul class="rating">
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
</ul>
<div class="product-prices">
<span class="sale-price"> €23.90</span>
<span class="regular-price">€21.03</span>
<span class="save">Save 12%</span>
</div>
<p class="product-description">Block out the haters with the fresh adidas® Originals Kaval Windbreaker Jacket. <br> Part of the Kaval Collection. <br> Regular fit is eased, but not sloppy, and perfect for any activity. <br> Plain-woven jacket specifically constructed for freedom of movement.</p>
<div class="product-size-color flex-wrap">
<div class="product-size">
<h5 class="title">Size</h5>
<select>
<option value="1">S</option>
<option value="2">M</option>
<option value="3">L</option>
<option value="4">XL</option>
</select>
</div>
<div class="product-color">
<h5 class="title">Color</h5>
<div class="color-input">
<div class="single-color color-1">
<input type="radio" id="radio-1" name="color">
<label for="radio-1"></label>
</div>
<div class="single-color color-2">
<input type="radio" id="radio-2" name="color">
<label for="radio-2"></label>
</div>
<div class="single-color color-3">
<input type="radio" id="radio-3" name="color">
<label for="radio-3"></label>
</div>
</div>
</div>
<div class="product-quantity">
<h5 class="title">Quantity</h5>
<div class="quantity d-flex">
<button type="button" id="sub" class="sub"><i class="fal fa-minus"></i></button>
<input type="text" value="1" />
<button type="button" id="add" class="add"><i class="fal fa-plus"></i></button>
</div>
</div>
</div>
<div class="product-add-cart">
<button><i class="icon ion-bag"></i> Add to cart</button>
</div>
<div class="product-wishlist-compare">
<ul class="d-flex flex-wrap">
<li><i class="fal fa-heart"></i> Add to wishlist</li>
<li><i class="fal fa-repeat"></i> Add to compare</li>
</ul>
</div>
<div class="product-share d-flex">
<p>Share</p>
<ul class="social media-body">
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-google"></i></li>
<li><i class="fab fa-pinterest-p"></i></li>
</ul>
</div>
</div> <!-- Modal Quick View Content -->
</div>
</div> <!-- row -->
</div> <!-- Modal Body -->
</div> <!-- Modal content -->
</div> <!-- Modal dialog -->
</div> <!-- Modal -->
Any easier ways other than creating x number of modals?
Thank you

Display Album Images using Bootstrap Modal per album

i created the bootstrap modal. the following images are albums cover images
<ul class="list-inline galleryItems">
#foreach($albums as $album)
<li data-toggle="modal" data-target="#myModal"><a href="#myGallery" data-slide-to=""><img src="{{ url('src/images/gallery/albums_cover',$album->photo->name) }}"><br>
Caption</a></li>
#endforeach
<!--end of thumbnails-->
and i had created the modal body and footer as follows
<div class="modal fade" id="myModal">
<br><br><br><br>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="pull-left">My Gallery Title</div>
<button type="button" class="close" data-dismiss="modal" title="Close"> <span class="glyphicon glyphicon-remove"></span></button>
</div>
<div class="modal-body">
<!--begin carousel-->
<div id="myGallery" class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="item active "> <img src="{{ url('src/images/gallery/albums_cover',$first_album->photo->name) }}" alt="item{{ $album->id }}" />
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
#foreach($albums as $album)
#foreach($album->photos as $photo)
<div class="item"> <img src="{{ url("src/images/gallery/album{$album->id}",$photo->name) }}" alt="" />
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
#endforeach
#endforeach
</div>
<!--Begin Previous and Next buttons-->
<a class="left carousel-control" href="#myGallery" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span></a> <a class="right carousel-control" href="#myGallery" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span></a>
<!--end carousel--></div>
<!--end modal-body--></div>
<div class="modal-footer">
<div class="pull-left">
<small>Photographs by Lorempixel.com</small>
</div>
<button class="btn-sm close" type="button" data-dismiss="modal">Close</button>
<!--end modal-footer--></div>
<!--end modal-content--></div>
<!--end modal-dialoge--></div>
<!--end myModal-->></div>
So, every time i click on any album, it shows me all the photos. i just want to display just the images that belongs to that folder
Thank you in advanced

Modal doesn't gets focused

I was trying to use a modal. When I try to click the modal, it doesn't get focused. I'm calling the modal in the top bar navigation that is dropdown(located in the top right side). I have uploaded a photo, the link is under the code. I'm using bootstrap. I got the snippet from here
My code:
<ul class="nav navbar-right top-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin User <b class="fa fa-angle-down">
</b></a>
<ul class="dropdown-menu">
<!--=====HERE IS WHERE I CALL THE MODAL=====-->
<li>
<a href="#" data-toggle="modal" data-target="#changeProfile"><i class="fa fa-fw fa-cog">
</i> Change Profile</a>
</li>
<li class="divider">
</li>
<li>
<a href="#"><i class="fa fa-fw fa-power-off">
</i> Logout</a>
</li>
</ul>
</li>
</ul>
<!-- Modal Add Brand -->
<div class="modal fade" id="changeProfile" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>
Change Profile
</h3>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="txtBusName" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" id="txtUsername" class="form-control">
</div>
</div>
<div class="form-group">
<label for="txtBusDesc" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" id="txtPassword" class="form-control">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
<!-- Modal Add Brand -->
This is what it looks like. I can't click the modal at all.
Thanks!
Seems like your modal box's z-index value is lower than the half-transparent dark div that is used to "block" the page content. Try increasing your modal box's z-index value.
#changeProfile {
z-index: 9999;
}

edit template bootstrap to display 4 product image at row

I am developing my application with laravel5.2 .I have template with bootstrap and want to display 4 products with their pictures at each row.
this is my template
#extends('layouts.layout',[['subscribe'=>$subscribe]])
#section('content')
<section id="advertisement">
<div class="container">
<img src="{{asset('images/shop/advertisement.jpg')}}" alt="" />
</div>
</section>
<section>
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="left-sidebar">
#include('shared.sidebar',array('brands'=>$brands))
</div>
</div>
<div class="col-sm-9 padding-right">
<div class="features_items"><!--features_items-->
<h2 class="title text-center">Features Items</h2>
#foreach ($products as $product)
<div class="col-sm-3">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="images/shop/{{$product->image}}" height="200" width="150" alt="">
<h2>{{$product->price}}</h2>
<h6><p>{{$product->name}}</p></h6>
<i class="fa fa-shopping-cart"></i>Add to cart
<i class="fa fa-info"></i>View Details
</div>
<div class="product-overlay">
<div class="overlay-content">
<h2>${{$product->price}}</h2>
<p>${{$product->name}}</p>
<form method="POST" action="{{url('cart')}}">
<input type="hidden" name="product_id" value="{{$product->id}}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-fefault add-to-cart">
<i class="fa fa-shopping-cart"></i>
Add to cart
</button>
</form>
<i class="fa fa-info"></i>View Details
</div>
</div>
</div>
<div class="choose">
<ul class="nav nav-pills nav-justified">
<li><i class="fa fa-plus-square"></i>Add to wishlist</li>
<li><i class="fa fa-plus-square"></i>Add to compare</li>
</ul>
</div>
</div>
</div>
#endforeach
<ul class="pagination">
<li class="active">1</li>
<li>2</li>
<li>3</li>
<li>»</li>
</ul>
</div><!--features_items-->
</div>
</div>
</div>
</section>
#endsection
It is not disciplined.it display 4 at row in time and 2 in time .please help me to do it.
In order to have nested columns (4*x columns sm-3 inside the column sm-9) you need to wrap the 4 columns in a row so that it becomes
<div class="col-sm-9">
<div class="row">
#foreach ($products as $product)
<div class="col-sm-3">
...

Categories