diff --git a/app/models/Location.php b/app/models/Location.php index df49df8dbf0e..7364e1c3a2d3 100755 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -21,7 +21,7 @@ public function users() { } public function assets() { - return $this->hasMany('Actionlog','location_id'); + return $this->hasManyThrough('Asset', 'Actionlog', 'location_id', 'id'); } public function assignedassets() { @@ -104,7 +104,7 @@ public function scopeTextsearch($query, $search) ->orWhere('city', 'LIKE', "%$search%") ->orWhere('state', 'LIKE', "%$search%") ->orWhere('zip', 'LIKE', "%$search%") - + // This doesn't actually work - need to use a table alias maybe? ->orWhere(function($query) use ($search) { $query->whereHas('parent', function($query) use ($search) {