I'm new in Laravel. I'm storing 3 types of user in my users table:
- admin : user_type_id = 1
- agent : user_type_id = 2
- farmer : user_type_id = 3
user_type_id column is in the users table.
In one of my Blade files, I want to only show the names of the agents. Here is my foreach loop, which is importing all 3 types of the user (it's showing the names of admins, agents and farmers).
@foreach($farmerPoint->user as $agent)
<tr>
<td>{{ $agent->name }}</td>
<td>{{ $agent->phone }}</td>
</tr>
@endforeach
<tr>...</tr>contents in something like this:@if ($agent->user_type_id === 2) <tr> ... </tr> @endif- see the Laravel Templates docs section titledIf Statements