I want to achieve this result, but I can't understand the logic of the sql implementation
here is my welcome.blade.php:
@extends('layouts/layout')
@section('content')
<div class="container-fluid">
@foreach ($categories as $category)
<h4>{{$category->category_name}}</h4>
<div class="row">
<div class="col-sm-4">
<h6>{{$category->item_name}}</h6>
</div>
</div>
@endforeach
</div>
@endsection
and my controller:
$categories = DB::table('items')
->join('categories', 'items.category_id', 'categories.id')
->select('items.item_name', 'items.item_price', 'categories.category_name', 'categories.description')
->groupBy('categories.category_name')
->get();
return view('welcome', 'categories'=> $categories]);