how to acess the data without using foreach loop in blade file
i don't know whether i can access the data without for each loop of blade file using laravel but still i need this for not repeating the values in the blade file because i am trying to add the filters heading properties like Color,Weight etc..
public function addProducts() {
$attributename = DB::table('attributes')->select('attribute_1',
'attribute_2','attribute_3','attribute_4','category_id')->get();
return view('showfilter',compact('attributename'));
}
in the blade file
@foreach($attributename as $attributenames)
{{ $attributenames->attribute_1 }}
{{ $attributenames->attribute_2 }}
@endforeach
So is the answer, you do always use a foreach on the view? . And use the backend to spit out what you want.
I just wanted the first item on a list on 1 part of the page and foreach the rest of the list on another part of the page. Seems alot of work to have to create a new query to just get the first item