Laravel Eager Load Multiple Polymorphic Relationships - some soft deletes, some not
<p>I have several models that contain a polymorphic field. These poly fields contain four or five relationships each, some are soft deleteable, some are not. I'm running into a 'damned if you do, damned if you don't' problem and not sure how to solve.</p>

<p>If I load with a call to eager loading without including trashed on the models that have softdeletes:</p>

<pre><code>$deptRisks = \App\DeptRisk::with(['owner', 'riskable']);
</code></pre>

<p>I will get the following error on those models that have been soft-deleted: </p>

<blockquote>
  <p>Trying to get property of non-object</p>
</blockquote>

<p>If I load WITH the withTrashed for the softdeletes:</p>

<pre><code>$deptRisks = \App\DeptRisk::with(['owner', 'riskable' =&gt; function ($query) {
        $query-&gt;withTrashed();
}]);
</code></pre>

<p>I will get the following error on those models that have NOT been set up as soft-deletes: </p>

<blockquote>
  <p>Call to undefined method
  Illuminate\Database\Query\Builder::withTrashed()</p>
</blockquote>

<p>I'm sure I'm missing something obvious, but I'm spinning in circles. Please help.</p>