title: How to make selection query for join tables in laravel?
body: <p>I have users and staffs tables. I want to display staff details after the login. The staff display will list the of staff with the same section with the user who login. For example, if Adam (section/seksyen=A) login, the staff list displayed are the staffs of section A.</p>
  
  <p>How to make query for that in laravel?</p>
  
  <p>table users:</p>
  
  <pre><code>  public function up()
  {
      Schema::create('users', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;string('name');
          $table-&gt;string('email')-&gt;unique();
          $table-&gt;string('password');
          $table-&gt;rememberToken();
          $table-&gt;timestamps();
          $table-&gt;string('section');
          $table-&gt;string('type');
      });
  }
  </code></pre>
  
  <p>table staffs:</p>
  
  <pre><code> public function up()
  {
      Schema::create('staffs', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;timestamps();
          $table-&gt;string('nama');
          $table-&gt;string('emel')-&gt;unique();
          $table-&gt;string('seksyen');
          $table-&gt;string('jawatan');
          $table-&gt;string('alamat');
          $table-&gt;string('no kakitangan');
      });
  </code></pre>
  
  <p>I have tried this query but doesn't work.</p>
  
  <pre><code> $data['data'] = DB::table('staffs')
                   -&gt;join('users', 'users.section', '=', 'staffs.seksyen')
                   -&gt;where('seksyen','=','Auth(section)')-&gt;get();
  </code></pre>