Trying to change Bootstraps column order for mobile, .col-order doesn't work cause its in a loop. Have $loop->iteration set for displaying different backgrounds on column 1, 4 or 5 for desktop, but for mobile i need some way of displaying them stacked as odds or evens, thanks.
<div class="row no-gutters bg-light">
#foreach ($products as $product)
<div class="col-12 col-xl-6 div-wo-bg #if($loop->iteration === 1 || $loop->iteration === 4 || $loop->iteration === 5) div-w-bg #endif">
Have tried an if statement:
<div class="row no-gutters bg-light">
#foreach ($products as $product)
#if ('className' == 'col-12')
<div class="col-12 col-xl-6 div-wo-bg #if($loop->iteration === 1 || $loop->iteration === 4 || $loop->iteration === 5) div-w-bg #endif">
#elseif ('className' == 'col-xl-6')
<div class="col-12 col-xl-6 div-wo-bg #if($loop->odd) div-w-bg #endif">
#endif
This just throws all the column display out of wack (for both mobile and desktop).
Try this
<div class="row no-gutters bg-light">
#foreach ($products as $key => $product)
<div class="col-12 col-xl-6 div-wo-bg {{ $key == 1 ? 'div-w-bg' : ($key == 4 ? 'div-w-bg' : ( $key == 5 ? 'div-w-bg' )) }}">
<!-- Latest Products Showcase Section
- The showcase design calls for columns to be side by side for desktop, but stacked for mobile. There are 2 differently styled bg's repeated throughout the layout of the columns.
- Because these columns are layed out differently, they both require 2 different $loop extensions to retrieve the bg's. So from within an if statement we use $loop->iteration for desktop but $loop->odd for mobile -->
<!-- Desktop Layout -->
<div class="container-fluid p-0">
<div class="row showcase-shop-products no-gutters bg-light">
#foreach ($products as $product)
<div class="col-6 d-none d-lg-flex div-wo-bg #if($loop->iteration === 1 || $loop->iteration === 4 || $loop->iteration === 5) div-w-bg #endif">
<div class="container-fluid">
<div class="row">
<!-- Column a (Text) -->
<div class="col-6 showcase-col">
<div class="overlay"></div>
<div class="showcase-hero">
<h2 class="card-title mb-4">{{ $product->name }}</h2>
<h3 class="card-subtitle text-muted">{{ $product->details }}</h3>
<h4 class="mb-3">{{ $product->presentPrice() }}</h4>
<p class="card-text mb-4 d-lg-none d-xxl-block">Lorem ipsum dolor sit amet consectetur adipisicing elit. At dicta accusamus quia aliquid minima animi alias.</p>
Add to Cart
</div>
</div>
<!-- Column b (Image) -->
<div class="col-6 showcase-col">
<img class="card-img-top products-img img-fluid" src="{{ asset("img/shop/products/".$product->slug.".png") }}" alt="Random product item">
<div class="overlay"></div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<!-- Mobile Layout -->
<div class="container-fluid p-0">
<div class="row showcase-shop-products no-gutters bg-light">
#foreach ($products as $product)
<div class="col-12 d-flex d-lg-none div-wo-bg #if($loop->odd) div-w-bg #endif">
<div class="container-fluid">
<div class="row">
<!-- Top Column (Image) -->
<div class="col-12 showcase-col">
<img class="card-img-top products-img img-fluid" src="{{ asset("img/shop/products/".$product->slug.".png") }}" alt="Random product item">
<div class="overlay"></div>
</div>
<!-- Bottom Column (Text) -->
<div class="col-12 showcase-col">
<div class="overlay"></div>
<div class="showcase-hero text-center pb-5">
<h2 class="card-title mb-4">{{ $product->name }}</h2>
<h3 class="card-subtitle text-muted">{{ $product->details }}</h3>
<h4 class="mb-3">{{ $product->presentPrice() }}</h4>
<p class="card-text mb-4 d-none xl-block">Lorem ipsum dolor sit amet consectetur adipisicing elit. At dicta accusamus quia aliquid minima animi alias.</p>
Add to Cart
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
Works perfectly now.
Related
Hi all I have some issue with my code ..
The idea is that I have multi room's which I retrieve from database every room have multi booking date my idea is to show when open room page all page if the room have current reservation mark it red or future reservation marked blue I can't know how to make this happen my room.blade is:
#section('content')
<div class="row text-right ">
#foreach ($room_typ as $a )
<div class="col-12 col-lg-2">
<div class="card radius-15">
<div class="card-body text-center radius-15">
<h4 title="{{ $a->r_det }}" class="mb-0 font-weight-bold mt-0 text-white">{{ $a->r_name }}
</h4>-<h6>{{ $a->f_name }}</h6>
<span class="mt-1 mb-1 acupp"></span>
<i class="bx bx-plus"></i>
<i class="fadeIn animated bx bx-trash-alt mr-md-3"></i>
<i class="bx bx-info-square mr-md-3"></i>
{{ $rr }} // should show the count for reservation with room number
</div>
</div>
</div>
#endforeach
</div>
#endsection
the controller is :
public function allrom()
{
$room_typ = addroom::all();
foreach ($room_typ as $dd) {
$rom = $dd->r_name;
$rr = res_c::where('rno', '=', $rom)->get();
}
echo view('room', compact('room_typ', 'rr'));
}
Try this please change the checkin and checkout fields with the one in your database let me know if it work
#section('content')
<div class="row text-right ">
#foreach ($room_typ as $a )
<div class="col-12 col-lg-2">
<div class="card radius-15" style="{{ date("Y-m-d") >= date("Y-m-d",strtotime($a->r_date_checkin)) && date("Y-m-d") < date("Y-m-d",strtotime($a->r_date_checkout)) ? "background-color:red" : ( date("Y-m-d") > date("Y-m-d",strtotime($a->r_date_checkin) ) ) ? "background-color:blue" : "" }}">
<div class="card-body text-center radius-15">
<h4 title="{{ $a->r_det }}" class="mb-0 font-weight-bold mt-0 text-white">{{ $a->r_name }}
</h4>-<h6>{{ $a->f_name }}</h6>
<span class="mt-1 mb-1 acupp"></span>
<i class="bx bx-plus"></i>
<i class="fadeIn animated bx bx-trash-alt mr-md-3"></i>
<i class="bx bx-info-square mr-md-3"></i>
{{ $rr }} // should show the count for reservation with room number
</div>
</div>
</div>
#endforeach
</div>
<div class="container mt-4 mb-4">
<div class="row">
<div class="col-lg-12">
<div id="blogCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
#foreach($reviews as $items)
<div class="carousel-item #if($loop->first) active #endif">
<div class="row">
#foreach($reviews as $review)
<div class="col-lg-4 ">
<a>
<div class="home1-img mt-3">
<?php
for($i=1;$i<6;$i++){
$check = '';
if($review->number_of_stars >= $i){
$check = 'checked';
}
echo '<span class="fa fa-star '.$check.'"></span>';
}
?>
<div class="home1-text mt-1" style="margin-bottom:30px;">
<p>{!! Illuminate\Support\Str::limit($review->customer_review,100) !!}</p>
<h5 class="text-color font-weight-bold">{{ $review->customer_name }}</h5>
</div>
</div>
</a>
</div>
#endforeach
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
I am getting all the records in all sides but I want 3 records in 1st slide then 3 records in 2nd slide and so on. I have tried many times but I am not able to fix it.
In laravel 5.7 in my web controller
public function index(Request $request){
$plan = Plan::All();
return view('web.plan.index', compact('plan'));
}
In my view file
#foreach($plan as $singlePlan)
#if(Carbon\Carbon::parse($singlePlan->date)->format('m')==10)
<div class="row brow bg-gray ">
<div class="col-md-12">
<div class="row-title">
<strong>12.31</strong>
</div>
</div>
</div>
<div class="m-departures">
<div class="row brow last-row" >
<div class="col-md-2 col-sm-2 col hidden-xs">
<div class="td center">Dec 21-22</div>
</div>
<div class="col-md-5 col-sm-5 col">
<div class="td">Fest</div>
</div>
<div class="col-xs-6 col visible-xs">
<div class="td">2 day</div>
</div>
<div class="col-md-1 col-sm-2 col hidden-xs">
<div class="td">2 day</div>
</div>
<div class="col-md-2 col-sm-3 col-xs-6 col">
<div class="td">
<span class="orange schedule-status">
4
</span>
</div>
</div>
<div class="col-md-2 col-xs-12 col tour-link hidden-sm hidden-xs">
<div class="td center"><a href="#" >view</a></div>
</div>
</div>
</div>
#endif
#endforeach
and my web looks like this
but I want it to look like this
How can I remove the duplicate title?
It would be better to group your data by the month before passing data to blade template. By using collection method mapToGroups
https://laravel.com/docs/8.x/collections#method-maptogroups
$planGroups = Plan::get()->mapToGroups(function($plan, $key) {
$planDate = \Carbon\Carbon::parse($plan->date);
return ["{$planDate->month} {$planDate->year}" => $plan];
})
->all();
You will get several groups of plans grouped by month, e.g.
[
'11 2020' => [plan, plan, ...],
'12 2020' => [plan, plan, plan, ...]
]
Then in your blade template you can loop through the months then loop through the plans.
#foreach ($planGroups as $month => $plans)
// show month heading
#foreach ($plans as $plan)
// show each plan
#endforeach
#endforeach
i have problem with for each loop that must get value from table and get sum and count from other tables depends on selected row in loop
here is my code :
$flights = Basic::all();
foreach ($flights as $flight) {
if($flight->cur_allowed_seats > '0'){
$basics_id = Basic::find($flight->id);
$inf_count = Ticket::where([['sector',$flight->sector],['pass_type','3'],['flight_date',$flight->flight_date]])->get()->count();
$child_count = Ticket::where([['sector',$flight->sector],['pass_type','2'],['flight_date',$flight->flight_date]])->get()->count();
$total_sale = DB::table('tickets')
->where([['sector', $flight->sector],['flight_date',$flight->flight_date]])
->sum('sale');
$free_seats_per1= DB::table('basics')->where('id', $flight->id)->first()->cur_total_seats;
$free_seats_per2= DB::table('basics')->where('id', $flight->id)->first()->total_seats;
$free_seats_per=$free_seats_per1/$free_seats_per2*100;
return view('home', array('flights' => $flights,'basics_id' => $basics_id,'inf_count' => $inf_count,
'child_count' => $child_count,'total_sale' => $total_sale,'free_seats_per' => $free_seats_per,
));
}
and here is blade code :
<div class="content-body">
#foreach($flights as $flight)
<h1 class="content-header-title mb-0">{{ $flight->sector }} <span style="color: red">{{ $flight->flight_date }}</span></h1>
<!-- eCommerce statistic -->
<div class="row">
<div class="col-xl-3 col-lg-6 col-12">
<div class="card pull-up">
<div class="card-content">
<div class="card-body">
<div class="media d-flex">
<div class="media-body text-left">
<h3 class="info" >{{ $flight->cur_total_seats }}</h3>
<h6 style="font-size:12px;font-weight: bold">المقاعد الشاغرة بحائل</h6>
</div>
<div>
<i class="icon-flag info font-large-2 float-right"></i>
</div>
</div>
<div class="progress progress-sm mt-1 mb-0 box-shadow-2">
{{-- {{ format_number((($basics_has->cur_total_seats/$basics_has->total_seats) * 100), 2) }}%--}}
<div class="progress-bar bg-gradient-x-info" role="progressbar" style="width: {{ $free_seats_per }}%"
aria-valuenow="80" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12">
<div class="card pull-up">
<div class="card-content">
<div class="card-body">
<div class="media d-flex">
<div class="media-body text-left">
<h3 class="info" >{{ $child_count }}</h3>
<h6 style="font-size:12px;font-weight: bold">عدد الأطفال المحجوز بحائل</h6>
</div>
<div>
<i class="icon-user-following info font-large-2 float-right"></i>
</div>
</div>
<div class="progress progress-sm mt-1 mb-0 box-shadow-2">
<div class="progress-bar bg-gradient-x-info" role="progressbar" style="width: {{ $flight->percent }}%"
aria-valuenow="80" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12">
<div class="card pull-up">
<div class="card-content">
<div class="card-body">
<div class="media d-flex">
<div class="media-body text-left">
<h3 class="success">{{$inf_count}}</h3>
<h6 style="font-size:12px;font-weight: bold">عدد الرضع المحجوز بحائل</h6>
</div>
<div>
<i class="la la-user success font-large-2 float-right"></i>
</div>
</div>
<div class="progress progress-sm mt-1 mb-0 box-shadow-2">
<div class="progress-bar bg-gradient-x-success" role="progressbar" style="width: 80%"
aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12">
<div class="card pull-up">
<div class="card-content">
<div class="card-body">
<div class="media d-flex">
<div class="media-body text-left">
<h3 class="danger">{{$total_sale}}</h3>
<h6 style="font-size:12px;font-weight: bold">إجمالي مبيعات حائل</h6>
</div>
<div>
<i class="la la-dollar danger font-large-2 float-right"></i>
</div>
</div>
<div class="progress progress-sm mt-1 mb-0 box-shadow-2">
<div class="progress-bar bg-gradient-x-danger" role="progressbar" style="width: 85%"
aria-valuenow="85" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
my problem is that any value from any table except 'Basic' it return only one value not loop
can any one help me with this issue please ?
So I'm having a little problem with using contact form 7 in a foundation reveal modal and was wondering if someone can help me a little with the following.
On a project I'm working on I have a product overview with lots of products. On every product there's a link that opens a contact form in a modal (reveal from foundation). In this modal I'm loading the contact form with get_template_part. This is working nicely but when I click on "send" the modal closes without sending the form and without a feedback message.
I would like to keep the modal open and include the "thank you" message or error message in this modal. I read something about using ajax but I'm not sure how to load the template part with ajax and not sure if thats the way to go.
I hope someone can help me in the right direction with this.
I added some code to make this a little bit more clear.
<div class="<?php echo $termsString; ?> item columns small-12 medium-6 large-3">
<div class="product-item">
<img class="assort-img" src="<?php the_post_thumbnail_url('td-product'); ?>" class="" alt="">
<div class="item-content">
<h5 class="item-title"><?php the_title(); ?></h5>
<div class="origin">
<span class="muted">Origin:</span> <br>
<span><?php the_field('origin'); ?></span>
</div>
<div class="availability">
<span class="muted">Availability:</span> <br>
<span><?php get_template_part('template-parts/content','availability'); ?></span>
</div>
Product Details
<hr>
<div class="more-info text-center">
<span class="hide">More info</span>
</div>
</div>
</div>
</div>
<div class="reveal full" id="itemContactModal-<?php the_ID(); ?>" data-reveal>
<?php get_template_part('template-parts/content','itemcontact'); ?>
</div>
And in content-item-contact i have the following:
<div class="contactdetails">
<div class="row">
<div class="small-12 columns">
<div class="row collapse">
<div class="column small-12 medium-4 large-3 white">
<div class="product-item">
<button class="close-button show-for-small-only" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
<img class="assort-img" src="<?php the_post_thumbnail_url('td-product'); ?>" class="" alt="">
<div class="item-content">
<h5 class="item-title"><?php the_title(); ?></h5>
<div class="origin">
<span class="muted">Origin:</span> <br>
<span><?php the_field('origin'); ?></span>
</div>
<div class="despription">
<p>Here you find productdetails and availability. Please contact us for more specific information.</p>
</div>
Product Details
</div>
</div>
</div>
<div class="column small-12 medium-8 large-9">
<div class="contact-wrapper">
<header >
<h4 class="contrast">Request more information</h4>
<button class="close-button show-for-medium" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</header>
<div class="contact-content clearfix">
<div class="">
<div class="column small-12">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. +31 (0) 76 522 1155</p>
</div>
<div class="column small-12">
<form>
<?php echo do_shortcode('[contact-form-7 id="138" title="Product Info"]'); ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>