I can't find the error, my categories are not shown according to their type, also does not throw laravel error..
blade.php
#extends('store.template')
#section('content')
<!-- Page Content -->
<div style="margin-top: 70px;" class="container text-center">
<!-- Page Heading -->
<div class="card bg-white ht-50 w-60">
<h1 class="">{{$tipo->tipo}}</h1>
</div>
<div style="margin-top: 10px;" class="row">
#foreach($categories as $category)
<div class="col-lg-4 col-sm-6 mb-4">
<div class="card h-100">
<a href="#">
#if(!empty($category->image))
<img class="card-img-top" src="{{url($category->image)}}" alt="">
#else
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
#endif
</a>
<div class="card-body">
<h4 class="card-title">
{{$category->name}}
</h4>
<p class="card-text">{{$category->descripcion}}</p>
</div>
</div>
</div>
#endforeach
</div>
<!-- /.row -->
</div>
<!-- /.container -->
#stop
controller:
public function categoryType($type)
{
$tipo = Tipo::where('tipo',$type)->first();
//dd($tipo->categories);
return view('store.categories-types')->with(['categories'=>$tipo->categories,'tipo'=>$tipo]);
}
in the table categories_type defined the categories
table categories:
error:
Related
I currently print all categories in one view, with them I mark a difference between its subcategories
#foreach($tipos as $tipo)
<div class="card">
<h4 style="margin-top: 5px;">{{$tipo->tipo }}</h4>
</div>
#foreach($tipo->categories as $category)
<div style="margin-top: 20px;" class="col-lg-4 col-sm-6 mb-4">
<div class="card h-100">
<a href="{{ route('category-detail',['slug'=>$category->slug]) }}">
#if(!empty($category->image))
<img class="card-img-top" src="{{url($category->image)}}" alt="">
#else
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
#endif
</a>
<div class="card-body">
<h4 class="card-title">
{{$category->name}}
</h4>
<p class="card-text">{{$category->descripcion}}</p>
</div>
</div>
</div>
#endforeach
#endforeach
I get the names from:
categories table:
Now I need to create a view for each of them, enter it using url,
controller:
public function list($id){
$tipos = App\Tipo::findOrFail($id);
return view('list.tipos', compact('tipos'));
}
route:
Route::get('/list{id}','HomeController#list')->name('list.categories');
pivot table:
How can I print the content of each category? help pls
Modify your controller like this
Note: Change the Model Names (App\Pivote) and (App\Category) to what you have set in your code.
public function list($id){
$tipos = App\Tipo::findOrFail($id);
$pivot_data = App\Pivote::select('category_id')->where('tipo_id',$id)->get()->toArray();
$categories = App\Category::whereIn('id',$pivot_data)->get()->toArray();
return view('list.tipos', compact('tipos','categories'));
}
And modify your view something like this
<div class="card">
<h4 style="margin-top: 5px;">{{$tipos->tipo }}</h4>
</div>
#foreach($categories as $key => $category)
<div style="margin-top: 20px;" class="col-lg-4 col-sm-6 mb-4">
<div class="card h-100">
<a href="{{ route('category-detail',['slug'=>$category['slug']]) }}">
#if(!empty($category['image']))
<img class="card-img-top" src="{{asset($category['image'])}}" alt="">
#else
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
#endif
</a>
<div class="card-body">
<h4 class="card-title">
{{$category['name']}}
</h4>
<p class="card-text">{{$category['descripcion']}}</p>
</div>
</div>
#endforeach
here is the function is given below
public function index(){
$student=Administration::Where('payment',1)->get();
//dd($student);
return view('HallAuthority.index',compact('student'));
}
Here is the view blade
<div class="container-fluid page-body-wrapper">
<div class="row row-offcanvas row-offcanvas-right">
<!-- partial:partials/_sidebar.html -->
#include('HallAuthority.inc.sidebar')
<!-- partial -->
<div class="content-wrapper">
<div class="row">
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
{{$student->count()}}
<h2 class="card-title">Total sutdent Student</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-1" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Total Department</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-2" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">stock price Price</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-3" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Revenue</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-4" class="card-float-chart"></div>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<!-- partial:partials/_footer.html -->
<div class="card card-body">
<div class="card-header text-center">
Mahfujur#2019
</div>
</div>
<!-- partial -->
</div>
<!-- row-offcanvas ends -->
</div>
The Route file is given below
Route::get('/student/hall','HallController#index')->name('student.hall');
Given this type an error
Undefined variable: student (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php) (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php)*
I get the value properly but i cannot compact this value to the view pages its always shows that it is undefined value i am totally fed up to solve this . Please anyone help me.
Try this
public function index(){
$student=Administration::Where('payment',1)->count();
return view('HallAuthority.index',compact('student'));
}
<div class="card-body">
{{$student}}
<h2 class="card-title">Total sutdent Student</h2>
</div>
I'm trying to browser the home page of particular script but I face this problem
"ErrorException (E_ERROR) No query results for model [App\User] 5
(View: /.../core/resources/views/newhome/home.blade.php)"
/home2/.../core/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php
Code:
$result = $this->find($id, $columns);
if (is_array($id)) {
if (count($result) == count(array_unique($id))) {
return $result;
}
} elseif (! is_null($result)) {
return $result;
}
throw (new ModelNotFoundException)->setModel(
get_class($this->model), $id
);
}
/**
* Find a model by its primary key or return fresh model instance.
*
* #param mixed $id
* #param array $columns
* #return \Illuminate\Database\Eloquent\Model
*/
public function findOrNew($id, $columns = ['*'])
{
if (! is_null($model = $this->find($id, $columns))) {
The View Code
#extends('layouts.newfrontend')
#section('style')
<link rel="stylesheet" href="{{ asset('assets/css/ion.rangeSlider.css') }}">
<link rel="stylesheet" href="{{ asset('assets/css/ranger-style.css') }}">
<link rel="stylesheet" href="{{ asset('assets/css/ion.rangeSlider.skinFlat.css') }}">
<style>
.price-table {
margin-bottom: 45px;
</style>
#endsection
#section('content')
<!--Header section start-->
<section id="particles-js" class="header-area header-bg" style="background-image: url('{{ asset('assets/images/slider') }}/{{$slider_text->image}}')">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<div class="header-section-wrapper">
<div class="header-section-top-part">
<div class="text-first wow slideInLeft" data-wow-duration="2s">{!!$slider_text->title!!}</div>
<p style="font-size: 1.5em;" class=" wow slideInDown" data-wow-duration="2s">{!!$slider_text->subtitle!!}</p>
</div>
<div class="header-section-bottom-part">
<div class="domain-search-from">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--Header section end-->
<div class="clearfix"></div>
<!-- Admin section start -->
<div class="admin-section wow slideInRight" data-wow-duration="2s">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- admin content start -->
<div class="admin-content">
<!-- admin text start -->
<div class="admin-text">
<p>Get access to Your account</p>
</div>
<!-- admin text end -->
<!-- admin user start -->
<div class="admin-user">
<button type="submit" name="login">sign in</button>
<button type="submit" name="register">register now</button>
</div>
<!-- admin user end -->
</div>
<!-- admin-content end -->
</div>
</div>
</div>
</div>
<!-- Admin section end -->
<div class="clearfix"></div>
<!-- Circle Section Start -->
<section class="circle-section section-padding wow slideInUp" data-wow-duration="2s">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-header">
<h2>HOW <span> {{ $basic_setting->title }} </span> Works </h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
</div>
</div>
<div class="row">
#foreach($features as $feature)
<div class="col-md-3">
<div class="circle-item wow flipInY" data-wow-duration="2s">
<img src="{{ asset('assets/images/features') }}/{{$feature->photo}}" alt="items">
<div class="circle-content">
<h6>{{$feature->title}}</h6>
<p>{{$feature->description}}</p>
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!-- Circle Section End -->
<div class="clearfix"></div>
<!--About community Section Start-->
<section class="section-padding sale-section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center">
<div class="sale-header wow slideInDown" data-wow-duration="2s">
<h2>about <span> {{ $site_title }} </span></h2>
</div>
<div class="sale-content">
<div class="row">
<div class="col-md-6 wow slideInLeft" data-wow-duration="2s">
<p class="about-community-text">
{!! $page->about_leftText !!}
</p>
</div>
<div class="col-md-6 wow slideInRight" data-wow-duration="2s">
<p class="about-community-text text-justify">
{!! $page->about_rightText !!}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--About community Section end-->
<div class="clearfix"></div>
<!--service section start-->
<section class="service-section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center section-padding padding-bottom-0 wow slideInLeft" data-wow-duration="2s">
<div class="section-header">
<h2>Our <span>Services</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p>{!! $page->service_subtitle !!}</p>
</div>
</div>
</div>
<div class="row wow slideInRight" data-wow-duration="2s">
#foreach($service as $s)
<div class="col-md-3 col-sm-6">
<div class="service-wrapper text-center">
<div class="service-icon ">
{!! $s->code !!}
</div>
<div class="service-title">
<p>{{ $s->title }}</p>
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!--service section end-->
<!--start investment plan-->
<section class="section-background">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center section-padding padding-bottom-0 wow slideInLeft" data-wow-duration="2s">
<div class="section-header">
<h2>Our awesome <span> plans</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p>{!! $page->plan_subtitle !!}</p>
</div>
</div>
</div>
<div class="row">
#foreach($plan as $p)
<div class="col-md-3 col-sm-6 pricing-list-botom-margin wow zoomIn" data-wow-duration="3s">
<!-- Pricing List1 Start -->
<div class="pricing-list1">
<div class="pricing-header1">
<h5>{{ $p->name }}</h5>
<p>{{ $p->compound->name }} {{ $p->percent }}% for {{ $p->time }} times</p>
</div>
<div class="pricing-info1">
<ul>
<li> <p>for <span class="color-text">{{ $p->time }}</span> times</p></li>
<li><p> <span class="color-text">{{ $p->percent }}%</span> roi each time</p></li>
</ul>
</div>
<div class="price-range">
<div class="row">
<div class="col-md-6 text-left col-sm-6 col-xs-6">
<div class="min-price">
<h6>Minimum<span class="color-text">{{ $basic->symbol }} {{ $p->minimum }}</span></h6>
</div>
</div>
<div class="col-md-6 text-right col-sm-6 col-xs-6">
<div class="min-price">
<h6>Maximum<span class="color-text">{{ $basic->symbol }} {{ $p->maximum }}</span></h6>
</div>
</div>
</div>
</div>
<div class="invest-type__profit plan__value--{{ $p->id }}">
<input type="text" value="{{ $basic->symbol }} {{ ($p->minimum + $p->maximum) / 2 }}" class="custom-input invest-type__profit--val" data-slider=".slider-input--{{ $p->id }}" style="color:#FFF; font-size: 25px">
<input type="hidden" name="amount" value="{{ ($p->minimum + $p->maximum) / 2 }}" class=" slider-input slider-input--{{ $p->id }}" data-perday="{{ $p->percent }}" data-peryear="{{ $p->time }}" data-min="{{ $p->minimum }}" data-max="{{ $p->maximum }}" data-dailyprofit=".daily-profit-{{ $p->id }}" data-totalprofit=".total-profit-{{ $p->id }} " data-valuetag=".plan__value--{{ $p->id }} .invest-type__profit--val"/>
</div>
<input type="hidden" name="plan_id" value="{{ $p->id }}">
<div class="price-range">
<div class="row">
<div class="col-md-6 text-left col-sm-6 col-xs-6 invest-type__calc invest-type__calc--daily">
<div class="min-price">
<h6>per time<span class="color-text"><b class="daily-profit-{{ $p->id }}">{{ $basic->symbol }} {{ (($p->minimum + $p->maximum) / 2 ) * $p->percent /100 }}.0</b></span></h6>
</div>
</div>
<div class="col-md-6 text-right col-sm-6 col-xs-6 invest-type__calc invest-type__calc--total">
<div class="min-price">
<h6>Total Return<span class="color-text"><b class="total-profit-{{ $p->id }}">{{ $basic->symbol }} {{ (((($p->minimum + $p->maximum) / 2) * $p->percent) /100 ) * $p->time }}.0</b></span></h6>
</div>
</div>
</div>
</div>
<!--Order Now!-->
</div>
<!-- Pricing List1 End -->
</div>
#endforeach
</div>
<div class="row section-padding padding-bottom-0">
<div class="col-md-6 col-sm-6">
<div class="contact-middel-info wow bounceInLeft" data-wow-duration="2s">
<div class="contact-middel-title">
<h4>Have a question <span>we are here to help!</span></h4>
</div>
<div class="contact-middel-details">
<p><i class="fa fa-phone"></i> {{ $basic->phone }}</p>
<p><i class="fa fa-envelope"></i> {{ $basic->email }}</p>
</div>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="discunt-middel-text wow bounceInRight" data-wow-duration="2s">
<h3>{{ $basic->reference_percent }}<i class="fa fa-percent"></i> <br /> referral <br /> commission</h3>
</div>
</div>
</div>
</div>
</section>
<!--end start investment plan-->
<!--Our Top Investor Section Start-->
<div class="clearfix"></div>
<section class="commission-section section-padding ">
<div class="container">
<!-- section header start -->
<div class="section-header wow slideInLeft" data-wow-duration="2s">
<h2>Our top <span> Investors</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p class="margin-b-35 wow slideInRight" data-wow-duration="2s">{{ $page->investor_subtitle }}</p>
<!-- section header end -->
<div class="row">
#php $i=1 #endphp
#foreach($top_investor as $key => $inv)
<div class="col-md-3">
<div class="referral-amount wow zoomIn" data-wow-duration="3s">
<p>{{ \App\User::findOrFail($inv->user_id)->name }}</p>
<h4><span> {{ $basic->symbol }} </span>{{ number_format($inv->total_invest) }}</h4>
<h5>{{$i++}}</h5>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!--Our Top Investor Section Start-->
<div class="clearfix"></div>
<!--staticies sectioin-->
<section class="sale-section section-padding">
<div class="container">
<div class="row">
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"><i class="fa fa-user"></i><p class="counter">{{ $total_user }}</p></div>
<div class="counter-content">
<p>Total User</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="2s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"> <i class="fa fa-recycle"></i><p class="counter">{{ $total_repeat }}</p></div>
<div class="counter-content">
<p>Total Repeat</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="4s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"> <i class="fa fa-cloud-download"></i><p class="counter">{{ $total_deposit }}</p></div>
<div class="counter-content">
<p>Total Deposit</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="6s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"><i class="fa fa-cloud-upload"></i><p class="counter">{{ $total_withdraw }}</p></div>
<div class="counter-content">
<p>Total Withdraw</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
</div>
</div>
</section>
<!--staticies sectioin end-->
<div class="clearfix"></div>
<!--testimonial section start-->
<section class="people-say-section section-padding">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- section header start -->
<div class="section-header wow bounceInLeft" data-wow-duration="2s">
<h2>What People <span>Say</span> </h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<!-- section header end -->
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="testimonial-area">
<div class="row">
<div class="col-lg-12 col-md-10 ">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-2">
<div class="testimonial-image-slider slider-nav text-center">
#foreach($testimonial as $tes)
<div class="sin-testiImage wow rotateIn" data-wow-duration="2s">
<img src="{{ asset('assets/images') }}/{{ $tes->image }}" alt="slider">
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 ">
<div class="testimonial-text-slider slider-for text-center wow bounceInRight" data-wow-duration="2s">
#foreach($testimonial as $tes)
<div class="sin-testiText">
<!-- people sat content list start -->
<div class="people-say-content-list " >
<h4>{{ $tes->name }}</h4>
<h6>{{ $tes->position }}</h6>
<ul>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
</ul>
<p>
{!! $tes->message !!}
</p>
</div>
<!-- people-say-content-list end -->
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- row -->
</section><!-- section -->
<!--testimonial section start-->
<div class="clearfix"></div>
<!--Deopsit and Payouts section start-->
<section class="hosting-section hosting-section1 section-padding section-background">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- section header start -->
<div class="section-header wow bounceInDown" data-wow-duration="3s">
<h2>Latest <span> Deposits & Withdraw</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<!-- section header end -->
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="section-wrapper wow bounceInLeft" data-wow-duration="2s">
<div class="deposit-title text-center">
<h4>Latest Deposits</h4>
</div>
<div class="hosting-content table-responsive">
<table>
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Currency</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
#foreach($latest_deposit as $ld)
<tr>
<td>{{ $ld->member->name }}</td>
<td>{{ \Carbon\Carbon::parse($ld->created_at)->format('M d,Y') }}</td>
<td><strong>{{ $basic->currency }}</strong></td>
<td><strong>{{ $basic->symbol }}{{ $ld->amount }}</strong></td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- hosting content end -->
</div>
</div>
<div class="col-md-6">
<div class="section-wrapper wow bounceInRight" data-wow-duration="2s">
<div class="deposit-title text-center">
<h4>Latest Withdraw</h4>
</div>
<div class="hosting-content table-responsive">
<table>
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Currency</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
#foreach($latest_withdraw as $ld)
<tr>
<td>{{ $ld->user->name }}</td>
<td>{{ \Carbon\Carbon::parse($ld->created_at)->format('M d,Y') }}</td>
<td><strong>{{ $basic->currency }}</strong></td>
<td><strong>{{ $basic->symbol }}{{ $ld->amount }}</strong></td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- hosting content end -->
</div>
</div>
</div><!-- row -->
</div><!-- container -->
</section>
<!--Deopsit and Payouts Section End-->
#endsection
#section('script')
<script type="text/javascript" src="{{ asset('assets/js/ion.rangeSlider.js') }}"></script>
<script type="text/javascript">
$(window).load(function() {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: true,
live: true
});
wow.init();
});
</script>
<script>
$.each($('.slider-input'), function() {
var $t = $(this),
from = $t.data('from'),
to = $t.data('to'),
$dailyProfit = $($t.data('dailyprofit')),
$totalProfit = $($t.data('totalprofit')),
$val = $($t.data('valuetag')),
perDay = $t.data('perday'),
perYear = $t.data('peryear');
$t.ionRangeSlider({
input_values_separator: ";",
prefix: '{{ $basic->symbol }} ',
hide_min_max: true,
force_edges: true,
onChange: function(val) {
$val.val( '{{ $basic->symbol }} ' + val.from);
var profit = (val.from * perDay / 100).toFixed(1);
profit = '{{ $basic->symbol }} ' + profit.replace('.', '.') ;
$dailyProfit.text(profit) ;
profit = ( (val.from * perDay / 100)* perYear ).toFixed(1);
profit = '{{ $basic->symbol }} ' + profit.replace('.', '.');
$totalProfit.text(profit);
}
});
});
$('.invest-type__profit--val').on('change', function(e) {
var slider = $($(this).data('slider')).data("ionRangeSlider");
slider.update({
from: $(this).val().replace('{{ $basic->symbol }} ', "")
});
})
</script>
#endsection
This line might be the cause of the problem
$inv->user_id is probably null, or deleted. You should check if each of the users
<p>{{ \App\User::findOrFail($inv->user_id)->name }}</p>
If you're okay with the user not existing,
(\App\User::find($inv->user_id))['name']
You shouldn't use something like this in your view. Try moving this in your controller.
{{ \App\User::findOrFail($inv->user_id)->name }}
Check $inv->user_id. It's either null or there's no user in database for this ID.
Trying to loop through my database and to post a bootstrap card for each "board member" in my database. However, with my current code, they post on top of each other, and I need them in rows. Here is my current code.
<div class="row">
<div class="col-sm-4 my-4">
#if(count($boardMembers) > 0)
#foreach($boardMembers as $boardMember)
<div class="card">
<img class="card-img-top" src="img/user1.jpg" alt="">
<div class="card-body">
<h2 class="card-title">{{$boardMember->name}}</h2>
<p class="card-text">{!!$boardMember->description!!}</p>
</div>
</div>
#endforeach
#else
<p>No Members Found</p>
#endif
</div>
</div>
You need to loop the .col part:
#if(count($boardMembers) > 0)
#foreach($boardMembers as $boardMember)
<div class="col-sm-4 my-4">
<div class="card">
<img class="card-img-top" src="img/user1.jpg" alt="">
<div class="card-body">
<h2 class="card-title">{{$boardMember->name}}</h2>
<p class="card-text">{!!$boardMember->description!!}</p>
</div>
</div>
</div>
#endforeach
#else
<p>No Members Found</p>
#endif
This will create multiple .cols with .cards but make sure you style the <p>No Members Found</p> or you can make it inside a .col too
Sorry for title i couldn't think better title!
anyway, this is my blog page code:
#extends('layouts.frontend_index')
#section('title', 'Blog')
#section('content')
<div class="container">
<div class="row" style="margin-bottom:30px;">
<div class="col-md-8">
<div class="row">
#forelse($posts as $post)
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12" style="margin-bottom:15px;">
<div class="card card2">
<div class="cardimg">
<img src="{{ url('images/') }}/{{ $post->image }}" class="card-img-top" style="width:100%; height:auto; max-height:500px;" alt="{{ $post->title }}">
</div>
<div class="card-block">
<h4 class="card-title">{{$post->title}}</h4>
<p class="card-text">{!! str_limit($post->body, 10) !!}</p>
<p><a class="btn btn-block btn-link" href="{{ route('frontshow', $post->slug ) }}">Read More <i class="fa fa-arrow-right"></i></a></p>
</div>
</div>
</div>
#empty
<p>No Post Available yet!</p>
<div class="text-center">
<a class="btn btn-error" href="{{url('/')}}">Back to Main Page</a>
</div>
#endforelse
<div class="col-md-12 text-center">
{{$posts->links()}}
</div>
</div><!--end row-->
</div><!--end col-md-8-->
<div class="col-md-4">
<h3>Get Latest Updates...</h3>
<a target="_blank" href="https://t.me/studiotjd"><div id="telegram"></div></a>
<a target="_blank" href="https://www.facebook.com/studiotjd"><div id="facebook"></div></a>
<a target="_blank" href="https://www.instagram.com/studiotjd/"><div id="instagram"></div></a>
</div><!--end col-md-4-->
</div><!--end row-->
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-4 span3 wow rollIn" style="animation-delay: 1s;"><div id="Library"></div></div><!--end col-md-4-->
<div class="col-md-4 span3 wow bounceInDown center" style="animation-delay: 1s;"><div id="Library2"></div></div><!--end col-md-4-->
<div class="col-md-4 span3 wow bounceInRight" style="animation-delay: 1s;"><div id="Library3"></div></div><!--end col-md-4-->
</div><!--end row-->
</div><!--end col-md-12-->
</div><!--end row-->
</div>
#endsection
here is how it looks like in view:
I tried almost everything to fix this issue but nothing works!
As you can see in my inspect all col-md-4 goes under first col-md-4 and i don't know why
Is there anyone knows how to fix this issue?
try this
{{ strip_tags(str_limit($post->body, 10)) }}
I think you have html element stored in your database, and you are just using str_limit so the tags in your body is not closed.
problem is a height of div, check it on the inspector code. 1 px or more is