Fix to bad relation definition in Location. (#4306)

This commit is contained in:
Brady Wetherington 2017-10-24 16:52:45 -07:00 committed by snipe
parent 8d68bb7a57
commit ad32bae62f

View file

@ -59,7 +59,18 @@ class Location extends SnipeModel
public function locationAssets()
{
return $this->hasMany('\App\Models\Asset', 'rtd_location_id')->orHas('assignedAssets');
/* This used to have an ...->orHas() clause that referred to
assignedAssets, and that was probably incorrect, as well as
definitely was setting fire to the query-planner. So don't do that.
It is arguable that we should have a '...->whereNull('assigned_to')
bit in there, but that isn't always correct either (in the case
where a user has no location, for example).
In all likelyhood, we need to denorm an "effective_location" column
into Assets to make this slightly less miserable.
*/
return $this->hasMany('\App\Models\Asset', 'rtd_location_id');
}
public function parent()