mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Use new dynamic scope where possible
This commit is contained in:
parent
054d71aedc
commit
b2b6f0cf96
|
@ -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.'%');
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue