1

I have a jobs table enter image description here

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

1
  • use where() condition Commented May 14, 2018 at 12:26

1 Answer 1

2
$jobs = job::where('schoolname', Auth::user()->name)->all();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.