Level 104
Any number of ways to approach this, e.g.
{{ $user->gender == "male" ? $user->mobile : '' }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I use "gender" attribute in Users table. my users are male and female. i want to show mobile number of only "Male" students in laravel blade view. This is my Code of users.blade.php
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<td>{{$user->fname}}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->mobile }}</td>// Here how to show only Male Students Mobile No.
@endforeach
</tbody>
</table>
Any number of ways to approach this, e.g.
{{ $user->gender == "male" ? $user->mobile : '' }}
Please or to participate in this conversation.