Reputation: 1216
focus on the schoolname column, what I want is that, I can only display all the values with the same column name, for example, I only want to display all the jobs that are related to [email protected].
[email protected] is also the value for Auth::user()->name
,
I have a blade in which it displays all the jobs, controller:
public function index()
{
$jobs = job::all();
return view('home',compact('jobs'));
}
blade:
<div class='col-lg-8 col-lg-offset-2'>
<center><h1>Jobs</h1></center>
<ul class="list-group">
@foreach ($jobs as $job)
<li class="list-group-item d-flex justify-content-between align-items-center">
<a href="{{'/home/'.$job->id}}">
<b>{{$job->jobposition}}</b></a>
<span class="pull-right">{{$job->created_at->diffForHumans()}}</span>
<p>{{$job->jobdesc}}</p>
</li>
@endforeach
</ul>
</div>
I want to display all the jobs that are created by the same person Auth::user()->name
I am new to this and I know this is an easy thing, so please forgive me and thank you for answering
Upvotes: 1
Views: 145
Reputation: 7923
$jobs = job::where('schoolname', Auth::user()->name)->all();
Upvotes: 2