diff --git a/app/models/Location.php b/app/models/Location.php index 7364e1c3a2..3b4226258f 100755 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -99,20 +99,24 @@ class Location extends Elegant public function scopeTextsearch($query, $search) { - return $query->where('name', 'LIKE', "%$search%") - ->orWhere('address', 'LIKE', "%$search%") - ->orWhere('city', 'LIKE', "%$search%") - ->orWhere('state', 'LIKE', "%$search%") - ->orWhere('zip', 'LIKE', "%$search%") + return $query->where('name', 'LIKE', "%$search%") + ->orWhere('address', 'LIKE', "%$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) { - $query->where(function($query) use ($search) { - $query->where('name','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) { + $query->where(function($query) use ($search) { + $query->where('name','LIKE','%'.$search.'%'); + }); + }) + // Ugly, ugly code because Laravel sucks at self-joins + ->orWhere(function($query) use ($search) { + $query->whereRaw("parent_id IN (select id from locations where name LIKE '%".$search."%') "); + }); + }); } diff --git a/app/views/backend/locations/index.blade.php b/app/views/backend/locations/index.blade.php index 3e15960c78..550d4aa77b 100755 --- a/app/views/backend/locations/index.blade.php +++ b/app/views/backend/locations/index.blade.php @@ -30,7 +30,8 @@ Locations :: @lang('general.id') @lang('admin/locations/table.name') @lang('admin/locations/table.parent') - @lang('general.assets') + @lang('admin/locations/table.assets_rtd') + @lang('admin/locations/table.assets_checkedout') @lang('general.currency') @lang('admin/locations/table.address') @lang('admin/locations/table.city')