Get Data from Two Tables

Posted 7 months ago by Bosstone

Hi, how can I get all the data from two tables:

users, projects

My tables are connected with user.id & projects.user_id

This is my Controller:

public function adminProjectShowAll() {
    
    $user = Auth::user();
    $stat = 1;
    $projects = Project::where('stat' <> $stat );

    
  return view('admin-project-show-all', compact('projects', 'user'));
    
}

my sql code would be: select * from users, projects where user.id = projects.user_id

This is my View:

@foreach($projects as $project)
                  <br>
                  <tr>
                    <td>{{ $project->name }}</td>
                    <td>{{ $project->user_id }}</td>
                    <td>{{ $project->cat_name }}</td>
                  </tr>
                  @endforeach 

Error: No Error, but nothing will be displayed...

Thank you for your help and support!

Best Regards,

Stefan

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.