This question already has an answer here:
Display the users with matching ID fields
staff details should only return when staffID(employer table) == id(staff table)
Below is my database schema
Staff('id' , 'username' , 'location');
Employer('id' , 'employerID','staffID' );
Below is what I have tried , however it is not return anything , i also have it returning to my blade file and a @foreach
loop to get the data.
I've tried have a model methods but no luck.
$following = DB::table('staff')
->select('username')
->join('employer' , 'employer.staffID', '=', 'staff.id')
->where('employer.employer_id' , '=', Auth::id())
->where('employer.staffID' ,'=', 'staff.id')
->get();
below is how I am trying to get my querys results to display in my blade
@foreach ($following as $userFound)
<p> {{ $userFound->username}}</p>
@endforeach
</div>