title: I want to get data of first table only by writing eloquent $query scoped function
body: <p>Please tell me the solution if exists. This is my code:</p>
  
  <pre><code>      public function handleRequest()
        {
             if (request()-&gt;filled('location_id')) {
                   $this-&gt;notification = $this-&gt;notification 
                      -&gt;whereHas('location', function ($query) 
                   {
                       $query-&gt;where('location_id', 
                               request('location_id'));
               });
            }
          return $this-&gt;notification;
         }
  </code></pre>
  
  <p>I want to get the data of the "notification" table only, but this query returns "Location" table's data too. I have to use the $query scoped solution.</p>