Get Data from Two Tables

Posted 2 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.