diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 333ebe51ab..32ffcfc3bf 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -947,13 +947,10 @@ class Asset extends Depreciable ->orWhere('assets_users.first_name', 'LIKE', '%'.$term.'%') ->orWhere('assets_users.last_name', 'LIKE', '%'.$term.'%') ->orWhere('assets_users.username', 'LIKE', '%'.$term.'%') - ->orWhereRaw( - $this->buildMultipleColumnSearch([ - DB::getTablePrefix().'assets_users.first_name', - DB::getTablePrefix().'assets_users.last_name', - ]), - ["%{$term}%"] - ); + ->orWhereMultipleColumns([ + DB::getTablePrefix() . 'assets_users.first_name', + DB::getTablePrefix() . 'assets_users.last_name', + ], $term); } /** @@ -1348,13 +1345,10 @@ class Asset extends Depreciable })->orWhere(function ($query) use ($search) { $query->where('assets_users.first_name', 'LIKE', '%'.$search.'%') ->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%') - ->orWhereRaw( - $this->buildMultipleColumnSearch([ - DB::getTablePrefix().'assets_users.first_name', - DB::getTablePrefix().'assets_users.last_name', - ]), - ["%{$search}%"] - ) + ->orWhereMultipleColumns([ + DB::getTablePrefix() . 'assets_users.first_name', + DB::getTablePrefix() . 'assets_users.last_name', + ], $search) ->orWhere('assets_users.username', 'LIKE', '%'.$search.'%') ->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%') ->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%'); diff --git a/app/Models/User.php b/app/Models/User.php index 464e20ea4c..a902e47379 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -646,13 +646,10 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo { return $query->where('first_name', 'LIKE', '%' . $search . '%') ->orWhere('last_name', 'LIKE', '%' . $search . '%') - ->orWhereRaw( - $this->buildMultipleColumnSearch([ - DB::getTablePrefix() . 'users.first_name', - DB::getTablePrefix() . 'users.last_name', - ]), - ["%{$search}%"] - ); + ->orWhereMultipleColumns([ + DB::getTablePrefix() . 'users.first_name', + DB::getTablePrefix() . 'users.last_name', + ], $search); } /** @@ -665,13 +662,10 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo public function advancedTextSearch(Builder $query, array $terms) { foreach($terms as $term) { - $query = $query->orWhereRaw( - $this->buildMultipleColumnSearch([ - DB::getTablePrefix() . 'users.first_name', - DB::getTablePrefix() . 'users.last_name', - ]), - ["%{$term}%"] - ); + $query->orWhereMultipleColumns([ + DB::getTablePrefix() . 'users.first_name', + DB::getTablePrefix() . 'users.last_name', + ], $term); } return $query;