Support the ongoing development of Laravel.io →
posted 2 weeks ago
0
moderator

Hello @arqeco

For this I should start by the State and load the users for the states

Example:

// in your service/controller
$states = State::query()
    ->with('users')
    ->orderBy('name')
    ->get();

// in your blade

<ul>
@foreach ($states as $state)
    <li>
        {{$state->name}}
        <ul>
        @foreach($state->users as $user)
            <li>{{$user->name}}</li>
        @endforeach
        </ul>
</li>
@endforeach
</ul>

This expect a state model that has a relation to the users.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.