title: Applying global scope with join replaces main table column data with joined table column data having same column name in Laravel 8
body: <p>I'm using a made up scenario, but facing similar issue.</p>
  <p>I'm using Laravel 8 and have two <strong>models</strong> <code>Family &amp; Centre</code>. Both containing common column name <code>id</code>.</p>
  <p>In model <code>Family</code> I want to restrict families data based on centre of user logged in. For now I'm hardcoding it a dummy centre_id</p>
  <p>Below is my <code>booted</code> function in <code>Family</code> model</p>
  <pre><code>protected static function booted()
      {
          static::addGlobalScope('user_access', function (Builder $builder) {
              $builder-&gt;join('centres as c1', function ($join) {
                   $join-&gt;on('families.centre_id', '=', 'c1.id');
              });
          });
      }
  </code></pre>
  <p>Now when I query <code>Family</code> model in a controller, it joins with <code>Centre</code> model and the <code>id</code> column of <code>Family</code> gets replaced with <code>Centre</code> model <code>id</code> column.</p>
  <p>For eg:</p>
  <p>Family has one row with id -&gt; 100 and centre_id = 1
  Centre has one row with id -&gt; 1 and name = 'Test'</p>
  <p>After join in booted function, I get value 1 in <code>id</code> when I query <code>$family-&gt;id</code>. <code>$family</code> is an instance of <code>Family</code> model.</p>
  <p>Expected result : 100</p>
  <p>I don't want to use select in booted function as there are many aggregated function I'm using which will be causing issues.</p>