php - How can limited span class item list in Laravel
More Description from the Pics:
I want to limited max item list at Laravel, As you if select all filter in admin panel, its look like this. So how can limited first 5 item to popular filters ?
<div class="g-attributes">
<span class="attr-title" style="color: orange"><b><i class="icofont-medal"></i> {{$translate_attribute->name ?? ""}}:</b> </span>
@foreach($termsByAttribute as $term )
@php $translate_term = $term->translateOrOrigin(app()->getLocale()) @endphp
<span class="item {{$term->slug}} term-{{$term->id}}" style="color: green" >{{$translate_term->name}}</span>
@endforeach
</div>
Answer
Solution:
You can use the Collection's take() method to grab the first 5 elements:
@foreach($termsByAttribute->take(5) as $term)
Answer
Solution:
Your question isnt very clear, but I am assuming that you want to be able retrieve the last 5 rows of the table, in your controller, you can get the records like this
$termsByAttribute = Table::latest()->take(5)->get();
Source