Unable to show category wise data in sections of home page - laravel

I want to fetch category wise data in home page's sections but I am unable to do this. Only one category section is working[enter image description here][1]
I made Section model and under this model Category model My IndexController Code :
<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Slider;
use App\Category;
use App\Section;
class IndexController extends Controller
{
public function index(){
$sliders = Slider::where('status',1)->get();
$categories = Category::with('sections')->where('status',1)->get();
//dd($categories);die;
return view('frontend.index')->with(compact('sliders','categories'));
}
}
and blade file code is :
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best tours</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Tours")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best stays</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Stays")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best cars</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Cars")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
only one tours section's categories is showing but not showing other categories

Yes Only one tour sections is showing because of this condition in your code
#if($category['sections']['section_name'] == "Tours")
........................
#endif

Related

wire:click only works for the first item in foreach in livewire

I want to open a model for edit item. I have added wire:click on a div but that only works for the first item of foreach.
Livewire Method
public function selectMealPlan($mealId)
{
$this->dispatchBrowserEvent('openEditMealModal');
}
View file
#foreach ($meal_plans as $meal)
<div class="meals-plan-item">
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
</div>
#endforeach
<script>
window.addEventListener('openEditMealModal', function() {
alert('hello');
})
</script>
The component should have only one root element, a div for example:
<div class="meals-plan-item">
#foreach ($meal_plans as $meal)
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
#endforeach
</div>

Dynamic Carousel In Laravel not displaying proper data

<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.

Only one image is displayed in the image carousel in bootstrap and laravel

I am trying to display images in bootstrap carousel but am not able to loop. Only one image is shown but not sliding.Am using laravel in the back end. Please assist if you can this is the code.
This is the code:
<div class="container">
<div class="row">
<div id="imageCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
#foreach($images as $value)
<li data-target="#imageCarouselIndicator" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
#endforeach
</ol>
<div class="carousel-inner">
<h3>{{$product->title}}</h3>
#foreach($images as $image )
<div class="item image {{ $loop->first ? 'active' : '' }}">
<div class="carousel-item active">
<img src="/images2/{{$image->filename}}" alt="{{$image->title}}">
</div>
</div>
#endforeach
</div>
<a class="carousel-control-prev" href="#imageCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#imageCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
Try this:
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
#foreach($images as $image )
<div class="carousel-item {{ $loop->first ? 'active' : '' }}">
<img src="/images2/{{$image->filename}}"/>
</div>
#endforeach
</div>
</div>

i want to add bootsnipp slider in codeigniter

Here is my main view page :
the first class: item active ,
and another is only class: item
but i want foreach only class="col-sm-6" with two class item active and item ...
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-sm-6">
<div class="col-item">
<div class="photo">
<img src="img/a.jpg" />
</div>
<div class="info">
<div class="row">
<div class="price col-md-6">
<h5>title</h5>
<h5 class="price-text-color">
Contact for price</h5>
</div>
<div class="rating hidden-sm col-md-6">
<i class="fa fa-bed"></i> <b>3</b>
<i class="fa fa-bath"></i> <b>2</b>
</div>
</div>
<div class="separator clear-left">
<p class="btn-details">
<i class="fa fa-list"></i>More details</p>
</div>
<div class="clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-sm-6">
<div class="col-item">
<div class="photo">
<img src="2.jpg" />
</div>
<div class="info">
<div class="row">
<div class="price col-md-6">
<h5>title</h5>
<h5 class="price-text-color">
Contact for price</h5>
</div>
<div class="rating hidden-sm col-md-6">
<i class="fa fa-bed"></i> <b>5</b>
<i class="fa fa-bath"></i> <b>3</b>
</div>
</div>
<div class="separator clear-left">
<p class="btn-details">
<i class="fa fa-list"></i>More details</p>
</div>
<div class="clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
but when i foreach the div one is active class but i want one div is active but another is not . actually i want to foreach col-sm-6 class.. how to do this. first
I assume that you want the following:
for there to be one active item
for each item to contain several col-sm-6 elements, created via a php foreach loop
create item via a php foreach loop
<!-- language: lang-php -->
<?php $active_item = "active" ?>
<?php foreach($itemlist as $item): ?>
<div class="item <?php echo $active_item ?>">
<?php $active_item = "" ?>
<div class="row">
<?php foreach($item as $column): ?>
<div class="col-sm-6">
<!-- insert your logic here for creating your columns in a carousel -->
</div>
<?php endforeach ?>
</div>
</div>
<?php endforeach ?>
$active will append the active class to only the first instance of your carousel items.
I avoided using foreach($array as $key=>$value) and checking the key for whether the item is to be active, as your array may not have numerical keys that begin with 0.

Multiple pagination in laravel 5.0

I have a laravel 5.0 project and i'm working with the pagination now but why is it not changing to the next page? Anyone knows or encounter this problem?
My Controller
public function($ship_id){
$members = Member::where('ship_id','=',$ship_id)->latest()->paginate(3);
$members->setPageName('members_page');
$pendings = AddRequest::where('ship_id','=',$ship_id)->paginate(3);
$pendings->setPageName('pendings_page');
return view('pages.Organization.List-Of-Organization-Scholar',compact('ship','schol','pendings','members','count_member','recommends'));
}
My View
#foreach($members as $member)
<div class="col-lg-4">
<div class="col-lg-12 well">
<a class="thumbnail" href="#">
<img class="img-responsive" src="../../{!! $member->Memscholar->scholar_image !!}" alt="" height="150" width="200">
</a>
<p>
<h3>{!! $member->Memscholar->scholar_lname !!}, {!! $member->Memscholar->scholar_fname !!}</h3>
</p>
</div>
</div>
#endforeach
<div class = "col-md-12">
{!! $members->appends(array_except(Request::query(), 'members_page'))->render()!!}
</div>
#foreach($pendings as $pending)
<div class="col-lg-4">
<div class="col-lg-12 well">
<a class="thumbnail" href="#">
<img class="img-responsive" src="../../{!! $pending->Pendscholar->scholar_image !!}" alt="" height="150" width="200">
</a>
</div>
</div>
#endforeach
<div class = "col-md-12">
{!! $pendings->appends(array_except(Request::query(), 'pendings_page'))->render()!!}
</div>

Resources