title: Filter using wildcard for relationships
body: <p>I have an input using a datalist where it's possible to either type in the name of the car part type or uses a dropdown. Looks like this</p>
  <pre><code>&lt;input value=&quot;{{ request()-&gt;input('part-type') }}&quot; list=&quot;part-type-list&quot;
          name=&quot;part-type&quot; class=&quot;form-select&quot;&gt;
  &lt;datalist id=&quot;part-type-list&quot;&gt;
      @foreach($partTypes as $partType)
          &lt;option @if(request()-&gt;input('plaintext') == $partType-&gt;name) selected
                  @endif value=&quot;{{$partType-&gt;name }}&quot;&gt;{{ $partType-&gt;name }}
          &lt;/option&gt;
      @endforeach
  &lt;/datalist&gt;
  </code></pre>
  <p>The <code>$partTypes</code> are coming from a query <code>CarPartType::all()</code> and it's used to show the values you can filter car parts by.</p>
  <p>In my controller, I am trying to see if I have a part-type filter and then changing the query to filter out the ones that don't match it. The problem is that I don't have the name of the car part types on the car parts table but only the id. Here is an example of me trying to query it through the relationship but it does not work.</p>
  <pre><code>$parts = CarPart::query();
  
  if($request-&gt;filled('part-type')) {
      $parts = $parts-&gt;where('carPartType.name', 'like', &quot;% $request-&gt;input('part-type')%&quot;);
      return $parts-&gt;get();
  }
  </code></pre>
  <p>The relationship I am trying to use</p>
  <pre><code>public function carPartType(): BelongsTo
  {
      return $this-&gt;belongsTo(CarPartType::class);
  }
  </code></pre>