i have a page "deposits" here are plans are availble with the use of "foreach"
now i wnt to show only plan number 3 here. mean plan of id 3.
<div class="row">
#foreach($plan as $p)
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
#endforeach
</div>
You can simply extract the plan from your $plan collection , does not need loop in below case
$p = $plan ->find(3);
if you want to use foreach and show plan id 3 , then try this :
<div class="row">
#foreach($plan as $p)
#if($p == 3)
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
#endif
#endforeach
</div>
But i suggest not to use foreach as you already know you need to show only plan id 3 . Try this :
<div class="row">
<?php $p = $plan["your_desired_id"]; ?> // means 2 or 3 .. whatever your desired id
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
</div>
If you need to find out a single value of plan from the collection .
You can just find it by it's plan id
$plan = Plan::find(3);
Write this in your controller and then pass it down to your view blade file by using with.
Example :
return view("blade file name")->with(['plan'=>$plan])
Later in your blade file just access it's fields.
{{$plan->field_name}}
Related
Tried all the possible solution to refresh the component but failed. Is there any option not to push the new comments and refresh the $comments variable whatever it contains?
Want to refresh $comments and its relation with replies in the blade on click of the send button
Calling $refresh action on the send button but it doesn't seem to work. Even tried to re-render the component with $this->render(). This also fails.
<div>
#foreach($comments as $item)
<div class="row" #if($item->reply_id != null) style="margin-left:40px;" #endif>
<div class="col-md-12">
<div class="py-md-4 py-3 border_bottom" >
<div class="row">
<div class="col-md-1 col-sm-1 col-1">
<div class="rating_person pt-3">
<img src="{{ isset($item->owner->profile_picture) ? asset($item->owner->profile_picture) : asset('images/default.jpg') }}">
</div>
</div>
<div class="col-md-11 col-sm-12 col-12">
<div class="rating_view_here_content_single_border">
<div class="rating_view_here_content_single">
<div class="rating_view_stars d-flex justify-content-between pt-3">
<div class="rating_view_heading">
<h4>{{ $item->owner->name }}</h4>
<div class="rating_wrapper">
<a href="#" class="grey_rating active-rating">
<i class="fa fa-star" aria-hidden="true"></i>
</a>
<a href="#" class="grey_rating active-rating">
<i class="fa fa-star" aria-hidden="true"></i>
</a>
<a href="#" class="grey_rating active-rating">
<i class="fa fa-star" aria-hidden="true"></i>
</a>
<a href="#" class="grey_rating active-rating">
<i class="fa fa-star" aria-hidden="true"></i>
</a>
<a href="#" class="grey_rating active-rating">
<i class="fa fa-star" aria-hidden="true"></i>
</a>
</div>
</div>
<span class="rating_days">{{ \App\Library\Helper::getTime($item->created_at) }}</span>
</div>
<div class="rating_comment_here pt-3">
<p>{{ $item->comment }}</p>
<p>
<a href="javascript:void(0)" class="reply" data-id="{{ $item->id }}" wire:click="toggleCommentBox({{ $item->id }}, 'true')">
<i class="fa fa-reply" aria-hidden="true"></i> <span>Reply</span>
</a>
</p>
</div>
#if($item_id == $item->id && $show=="true")
<div class="video_inner_form_wrapper commentBox-{{ $item->id }}">
<form wire:submit.prevent="sendReply" class="row">
<input type="hidden" name="reply_id" value="{{ $item->id }}">
<div class="comment_input col-md-8">
<input type="text" class="bluish_label video_inner_input #error('replyText') is-invalid #enderror" wire:model.lazy="replyText" placeholder="Write your comment here">
#error('replyText')
<div class="invalid-feedback">{{$message}}</div>
#enderror
</div>
<div class="col-md-4">
<button type="submit" class="btn_edit text-uppercase" wire:click="$refresh">Send</a>
<button type="button" class="btn_edit text-uppercase cancel" wire:click="toggleCommentBox({{ $item->id }}, 'false')">Cancel</a>
</div></form>
</div>
#endif
</div>
</div>
</div>
</div>
</div>
<livewire:frontend.discussion-chat :key="'chat-' . $item->id" :comments="$item->replies" :id="$model_id" :type="$model_type" />
</div>
</div>
#endforeach
</div>
Since none of the properties is updated, the livewire chat component will not refresh.
Possible solution is not to pass the list as a param but fetch it inside the chat component. Use events to trigger a refresh:
#click="$emit('discussion.chat.{{ $id }}.refresh')"
Inside frontend.discussion-chat have a
public function listeners(): array
{
return [
"discussion.chat.$this->id.refresh" => "reload"
];
}
public function reload(): void
{
// E.g.
$this->comments->fresh();
}
I wrote the following code to display some products on a page but all that I want is to display only 3 items in a row.
My code for displaying all products (i have to display more than 15 products):
<div class="products">
<div class="row">
#foreach($products as $item)
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div class="blog-item item swin-transition">
<div class="block-img">
<img style="width: 269.844px;height: 254.984px " src="{{url('images/product/'.$item['image'])}}" alt="" class="img img-responsive">
<div class="group-btn">
<i class="icons fa fa-link"></i>
<i class="fa fa-shopping-basket"></i>
</div>
</div>
<div class="block-content">
<h6 class="title" style="font-size: 15px">
{{$item['name_'.$lang]}}
</h6>
<div class="product-info">
<ul class="list-inline">
<li class="author">
<span>{{Lang::get('frontend.price')}}:</span>
<span class="text">{{number_format($item['online_price'])}} {{Lang::get('frontend.unit')}}</span>
</li>
<li class="rating">
<a href="javascript:void(0)" tabindex="0">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
php `array_chunk()` function will serve your purpose [http://php.net/manual/en/function.array-chunk.php][1]
<div class="products">
#foreach(array_chunk($products,3,true) as $chunk)
<div class="row">
#foreach($chunk as $item)
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div class="blog-item item swin-transition">
<div class="block-img">
<img style="width: 269.844px;height: 254.984px " src="{{url('images/product/'.$item['image'])}}" alt="" class="img img-responsive">
<div class="group-btn">
<i class="icons fa fa-link"></i>
<i class="fa fa-shopping-basket"></i>
</div>
</div>
<div class="block-content">
<h6 class="title" style="font-size: 15px">{{$item['name_'.$lang]}}</h6>
<div class="product-info">
<ul class="list-inline">
<li class="author"><span>{{Lang::get('frontend.price')}}:</span><span class="text">{{number_format($item['online_price'])}} {{Lang::get('frontend.unit')}}</span></li>
<li class="rating"><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i></li>
</ul>
</div>
</div>
</div>
</div>
#endforeach
</div>
#endforeach;
</div>
[1]: http://php.net/manual/en/function.array-chunk.php
I have a page "https://proj.test/user/profile?user=2#myRegistrations" where I have two tabs, one tab show the past registrations of a user in conferences and other tab the next registrations of the user in a conference. The user can click "Past Registrations" to check the past registrations and click in "Next Registrations" to check his next registrations in conferences. And its working.
In this same page, above the tabs, I have a form for the user to search for a conference name where he his registered. But when the user enters some text in the form search input like "test" and click in "Search" it appears "Undefined property: Illuminate\Pagination\LengthAwarePaginator::$participants (View: /Users/john/projects/proj/resources/views/users/index.blade.php)". Do you know what can be the issue?
Code in he view:
<div class="tab-pane clearfix fade" id="myTickets" role="tabpanel" aria-labelledby="contact-tab">
<div class="d-flex justify-content-between">
<form method="get" class="clearfix w-75" method="POST" action="{{ route('user.searchRegistration') }}">
{{ csrf_field() }}
<div class="form-group col col-md-6 px-0">
<div class="input-group" data-provide="datepicker">
<input type='text' class="form-control" placeholder="Search Registrations"
name="search_registration"
value="{{old('search_registration')}}"/>
<button class="input-group-addon">Search</button>
</div>
</div>
</form>
<a href="{{route('user.cleanSearchRegistration')}}" class="btn btn-outline-primary"
id="cleanSearchRegistration">Clean Search</a>
</div>
#if(session('searchedRegistrations'))
#if(session('searchedRegistrations')->count() != null)
#foreach(session('searchedRegistrations') as $registration)
#foreach(session('searchedRegistrations')->participants as $participant)
#if(!empty($registration))
<li class="list-group-item">
<h5>{{optional($registration->conference)->name}}</h5>
#if ($registration->status == 'C')
<a href="{{route('conference.registrationInfo',
['id' => $registration->conference->id,
'slug' => $registration->conference->slug,
'regID'=> $registration->id])}}"
class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Registration document
</a>
#endif
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',
[
'regID'=> $registration->id])}}"
class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Download certificate
</a>
#break
#endif
</li>
#endif
#endforeach
#endforeach
<div class="text-center d-flex justify-content-center mt-3">
{{session('searchedRegistrations')->fragment('searchRegistrations')->links("pagination::bootstrap-4")}}
</div>
#else
<div class="alert alert-info" role="alert">
<i class="material-icons">info</i>
<span>Your search didnt return any result.</span>
</div>
#endif
#else
<div class="d-flex mb-3">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active border" href="#nextConferences" data-toggle="tab" role="tab">Next
Conferences</a>
</li>
<li class="nav-item">
<a class="nav-link border" href="#PastRegistrations" data-toggle="tab" role="tab">Past
Conferences</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active clearfix" id="nextConferences" role="tabpanel"
aria-labelledby="home-tab">
<ul class="list-group">
#foreach($nextRegistrations as $nextRegistration)
#foreach($nextRegistration->participants as $participant)
#if(!empty($nextRegistration->conference) || !empty($nextRegistration->conference->start_date))
<li class="list-group-item">
<h5>{{optional($nextRegistration->conference)->name}}</h5>
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',
[
'regID'=> $nextRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Download Certificate</a>
#break
#endif
#if ($nextRegistration->status == 'C')
<a href="{{route('conferences.registrationInfo',
[
'regID'=> $nextRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Registration document
</a>
#endif
</li>
#endif
#endforeach
#endforeach
</ul>
<div class="text-center d-flex justify-content-center mt-3">
{{$nextRegistrations->fragment('nextConferences')->links("pagination::bootstrap-4")}}
</div>
</div>
<div class="tab-pane fade show clearfix" id="pastConferences" role="tabpanel" aria-labelledby="home-tab">
<ul class="list-group">
#foreach($pastRegistrations as $pastRegistration)
#foreach($pastRegistration->participants as $participant)
#if(!empty($pastRegistration->conference) || !empty($pastRegistration->conference->start_date))
<li class="list-group-item">
<h5>{{optional($pastRegistration->conference)->name}}</h5>
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',['regID'=> $pastRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Download Certificate
</a>
#break
#endif
#if ($pastRegistration->status == 'C')
<a href="{{route('conferences.registrationInfo',
[
'regID'=> $pastRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Registration info
</a>
#endif
</li>
#endif
#endforeach
#endforeach
</ul>
<div class="text-center d-flex justify-content-center mt-3">
{{$pastRegistrations->fragment('pastConferences')->links("pagination::bootstrap-4")}}
</div>
</div>
</div>
</div>
I assume session('searchedRegistrations') is the Pagination instance. There is no property named participants nor would there be any random properties (it is a container, not what it contains). I would imagine a model instance contained in the collection might have a participants property though.
#foreach(session('searchedRegistrations') as $registration)
#foreach(session('searchedRegistrations')->participants as $participant)
I am guessing that should be
#foreach($registration->participants as $participant)
I need check My Laravel app with current logging user id(Auth) and user_id in task table and run if else command. I need show task_name in task table with different user_id. among them if user_id is equal to current I need show following items on My blade file.
#foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<i class="glyphicon glyphicon-plus"></i>
</div>
<h4><i class="fa fa-check-square-o"></i> <span>{{ $task->task_name }}
</span></h4>
</div>
</li>
</ul>
<hr>
#endforeach
and if task user_id is not equels to Auth id should display following items
#foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<i class="glyphicon glyphicon-plus"></i>
<i class="glyphicon glyphicon-pencil"></i>
<i class="glyphicon glyphicon-trash"></i>
</div>
<h4><i class="fa fa-check-square-o"></i> <span>{{ $task->task_name }}
</span></h4>
</div>
</li>
</ul>
<hr>
#endforeach
how can do this?
My task table as this
id task_name user_id
1 dfr 1
2 bgh 2
3 hyg 1
4 hyu 4
You can use the auth() helper. These helpers are available on both blade files and Controllers.
#foreach ($project->tasks as $task)
#if(auth()->user()->id == $task->user_id)
// do something
#else
// do something
#endif
#endforeach
Then that's it.
You need to compare auth user with your task user variable in if condition and then display the data like below:
#if(auth()->user()->id == $task->user_id)
#foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i>
</a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}
</a>
</span></h4>
</div>
</li>
</ul>
<hr>
#endforeach
#else
#foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i>
</a>
<i class="glyphicon glyphicon-pencil"></i>
<a href="" class="editInline"><i class="glyphicon glyphicon-trash">
</i></a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}
</a>
</span></h4>
</div>
</li>
</ul>
<hr>
#endforeach
#endif
You can also #if condition within #foreach to just use it once if both #foreach are same and can update your code like below:
#foreach ($project->tasks as $task)
#if(auth()->user()->id == $task->user_id)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i>
</a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}
</a>
</span></h4>
</div>
</li>
</ul>
<hr>
#else
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i>
</a>
<i class="glyphicon glyphicon-pencil"></i>
<a href="" class="editInline"><i class="glyphicon glyphicon-trash">
</i></a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}
</a>
</span></h4>
</div>
</li>
</ul>
<hr>
#endif
#endforeach
The laravel paginator does work, but not good in my case.
So I have a forum with comments and the paginator must display when there are more than 10 comments on that page.
So I have a topic that has more than 10 comments and then it works fine on that page, but when I go to another page, he does take the pagination of the most comments. That is not what I want.
Here are some screens and code:
Here are there more than 10 comments, so it is good that it displays the paginator. The strange thing here is that it only shows 2 comments and not 10.
Here is another topic with just 8 comments, so the pagination shouldn't display anything:
But as you can see, it does show the paginator....
My code look like this:
Controller:
public function thread($title)
{
$thread = Thread::where('title', '=', str_replace('Thread-', '',str_replace('-', ' ', $title)))->first();
$usercolor = DB::table('threads')
->join('user', 'threads.uid', '=', 'user.id')
->join('role', 'user.role_id', '=', 'role.id')
->where('threads.uid', '=', $thread->uid)
->first();
$usertitle = DB::table('threads')
->join('user', 'threads.uid', '=', 'user.id')
->where('threads.uid', '=', $thread->uid)
->first();
$comments = Comment::orderBy('posted_at', 'asc')
->where('deleted_at', '=', '0000-00-00 00:00:00')
->with('user.role')
->paginate(10);
if (!$thread) {
return die('bestaat niet!');
}else{
return View::make('thread')->with('threads', $thread)
->with('comments', $comments)
->with('usercolor', $usercolor)
->with('usertitle', $usertitle);
}
}
View:
#include('globs.header')
<div class="col-sm-offset-1 col-sm-10">
<div class="clearfix"> </div>
#if(Request::get('page', 1) == 1)
<div class="panel panel-default" id="a9">
<div class="panel-heading">
<div class="panel-title">{{ $threads->title }}
</div>
</div>
<div class="panel-body thread-row">
<div class="row thread-row">
<div class="col-md-2 col-sm-3 text-center userblock">
<div class="clerafix"> </div>
<img class="img-thumbnail avatar" src="./public/img/avatar.jpg" alt="Avatar" height="55px;" width="55px">
<div class="push_bottom_5" style="color:{{ $usercolor->colour }};"><strong>{{ $threads->username }}</strong></div>
<div class="push_bottom_5"><small>{{ $usertitle->usertitle }}</small></div>
<div class="label label-default" style="background-color:{{ $usercolor->colour }};">{{ $usercolor->name }}</div>
<div class="push_bottom_5">
#if($usercolor->id == '1')
<i class="fa fa-star"></i>
#elseif($usercolor->id == '2')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($usercolor->id == '3')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($usercolor->id == '4')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($usercolor->id == '5')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($usercolor->id >= '6')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#endif
</div>
<div class="text-muted text-left"><small>Total Posts: 66</small></div>
<div class="text-muted text-left"><small>Joined 05-11-2014</small></div>
<div class="clerafix"> </div>
</div>
<div class="col-md-5 col-sm-6 col-xs-8">
<div class="clerafix"> </div>
<div class="text-muted"><span><i class="fa fa-calendar"></i> </span><small>
<span>Posted:</span> {{ date("d-m-Y", strtotime($threads->date_posted)) }}</small></div>
</div>
<div class="col-md-10 col-sm-9 col-xs-12">
<div class="clerafix"> </div>
<div class="content_body"><p>{{ Helper::Filter(BBCode::parse($threads->message)) }}</p>
</div>
<div class="clerafix"> </div>
</div>
</div>
</div>
<div class="panel-footer clearfix">
<div class="pull-right">
<!-- acties -->
<button class="btn btn-primary btn-sm"><i class="fa fa-edit"></i> Aanpassen</button>
<button class="btn btn-primary btn-sm"><i class="fa fa-quote-left"></i> Quote</button>
<button class="btn btn-danger btn-sm"><i class="fa fa-trash"></i> Verwijder</button>
<button class="btn btn-warning btn-sm"><i class="fa fa-exclamation"></i> Rapporteer</button>
</div>
</div>
</div>
<!-- end of the topic -->
</div>
#endif
<!-- begin of comments -->
#foreach($comments as $comment)
#if($comment->tid == $threads->tid)
<div class="col-sm-offset-1 col-sm-10">
<div class="clearfix"> </div>
<div class="panel panel-default" id="a9">
<div class="panel-body thread-row">
<div class="row thread-row">
<div class="col-md-2 col-sm-3 text-center userblock">
<div class="clerafix"> </div>
<img class="img-thumbnail avatar" src="./public/img/avatar.jpg" alt="Avatar" height="55px;" width="55px">
<div class="push_bottom_5" style="color:{{ $comment->user->role->colour }};"><strong>{{ $comment->username }}</strong></div>
<div class="push_bottom_5"><small>{{ $comment->user->usertitle }}</small></div>
<div class="label label-default" style="background-color:{{ $comment->user->role->colour }};">{{ $comment->user->role->name }}</div>
<div class="push_bottom_5">
#if($comment->user->role->id == '1')
<i class="fa fa-star"></i>
#elseif($comment->user->role->id == '2')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($comment->user->role->id == '3')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($comment->user->role->id == '4')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($comment->user->role->id == '5')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#elseif($comment->user->role->id >= '6')
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
#endif
</div>
<div class="text-muted text-left"><small>Total Posts: 66</small></div>
<div class="text-muted text-left"><small>Joined 05-11-2014</small></div>
<div class="clerafix"> </div>
</div>
<div class="col-md-5 col-sm-6 col-xs-8">
<div class="clerafix"> </div>
<div class="text-muted"><span class="hidden-md "><i class="fa fa-calendar"></i>
</span><small><span>Posted:</span> {{ date("d-m-Y", strtotime($comment->posted_at)) }}</small></div>
</div>
<div class="col-md-10 col-sm-9 col-xs-12">
<div class="clerafix"> </div>
<div class="content_body"><p>{{ Helper::Filter(BBCode::parse($comment->comment)) }}</p>
</div>
<div class="clerafix"> </div>
</div>
</div>
</div>
<div class="panel-footer clearfix">
<div class="pull-right">
<!-- acties -->
<button class="btn btn-primary btn-sm"><i class="fa fa-edit"></i> Aanpassen</button>
<button class="btn btn-primary btn-sm"><i class="fa fa-quote-left"></i> Quote</button>
<button class="btn btn-danger btn-sm"><i class="fa fa-trash"></i> Verwijder</button>
<button class="btn btn-warning btn-sm"><i class="fa fa-exclamation"></i> Rapporteer</button>
</div>
</div>
</div>
</div>
#endif
#endforeach
<!-- end of comments -->
#if(Auth::check())
<div class="col-sm-offset-1 col-sm-10">
<div class="clearfix"> </div>
<div class="panel panel-default" id="a9">
<div class="panel-heading"><h4>Snelle reactie plaatsen</h4></div>
<div class="panel-body">
{{ Form::open(array('url' => 'SubmitComment')) }}
<input type="hidden" value="{{ $threads->tid }}" name="tid">
{{ Honeypot::generate('spamprt', 'time') }}
<textarea name="comment" class="form-control" col="250" rows="5" placeholder="Typ uw bericht..."></textarea>
<div class="clearfix"> </div>
<button class="btn btn-success pull-left" type="submit" name="action">
Reageer
</button>
{{ Form::close() }}
</div>
</div>
</div>
#endif
<div class="col-md-4 col-md-offset-5">{{ $comments->links() }}</div>
</div>
</div>
#include('globs.footer')
I hope you guys will understand my problem and are be able to find a perfect solution with me.
It looks like you always retrieve all comments. I can also see this in your template, where you wrap your code in #if($comment->tid == $threads->tid) within your foreach.
This means that later in your template, where you retrieve the pagination links, it will retrieve the links for all comments, but not all comments are shown in the page, since you filter them manually in the loop.
Query the comments like
$comments = Comment::orderBy('posted_at', 'asc')
->where('deleted_at', '=', '0000-00-00 00:00:00')
->where('tid', $threads->tid) // it's about this line!
->with('user.role')
->paginate(10);
Note:
Above should provide a solution for your problem, but as an extra, you could also look into relationships. As an addition, this answer on SO "Laravel 4.1: How to paginate eloquent eager relationship?" (Since you tagged your post with Laravel-4) has some nice arguments on how to approach this efficiently.