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.first_name', 'LIKE', '%'.$term.'%')
|
||||||
->orWhere('assets_users.last_name', 'LIKE', '%'.$term.'%')
|
->orWhere('assets_users.last_name', 'LIKE', '%'.$term.'%')
|
||||||
->orWhere('assets_users.username', 'LIKE', '%'.$term.'%')
|
->orWhere('assets_users.username', 'LIKE', '%'.$term.'%')
|
||||||
->orWhereRaw(
|
->orWhereMultipleColumns([
|
||||||
$this->buildMultipleColumnSearch([
|
DB::getTablePrefix() . 'assets_users.first_name',
|
||||||
DB::getTablePrefix().'assets_users.first_name',
|
DB::getTablePrefix() . 'assets_users.last_name',
|
||||||
DB::getTablePrefix().'assets_users.last_name',
|
], $term);
|
||||||
]),
|
|
||||||
["%{$term}%"]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1348,13 +1345,10 @@ class Asset extends Depreciable
|
||||||
})->orWhere(function ($query) use ($search) {
|
})->orWhere(function ($query) use ($search) {
|
||||||
$query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
|
$query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
|
||||||
->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
|
->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
|
||||||
->orWhereRaw(
|
->orWhereMultipleColumns([
|
||||||
$this->buildMultipleColumnSearch([
|
DB::getTablePrefix() . 'assets_users.first_name',
|
||||||
DB::getTablePrefix().'assets_users.first_name',
|
DB::getTablePrefix() . 'assets_users.last_name',
|
||||||
DB::getTablePrefix().'assets_users.last_name',
|
], $search)
|
||||||
]),
|
|
||||||
["%{$search}%"]
|
|
||||||
)
|
|
||||||
->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
|
->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
|
||||||
->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
|
->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
|
||||||
->orWhere('assigned_assets.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 . '%')
|
return $query->where('first_name', 'LIKE', '%' . $search . '%')
|
||||||
->orWhere('last_name', 'LIKE', '%' . $search . '%')
|
->orWhere('last_name', 'LIKE', '%' . $search . '%')
|
||||||
->orWhereRaw(
|
->orWhereMultipleColumns([
|
||||||
$this->buildMultipleColumnSearch([
|
DB::getTablePrefix() . 'users.first_name',
|
||||||
DB::getTablePrefix() . 'users.first_name',
|
DB::getTablePrefix() . 'users.last_name',
|
||||||
DB::getTablePrefix() . 'users.last_name',
|
], $search);
|
||||||
]),
|
|
||||||
["%{$search}%"]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -665,13 +662,10 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
public function advancedTextSearch(Builder $query, array $terms) {
|
public function advancedTextSearch(Builder $query, array $terms) {
|
||||||
|
|
||||||
foreach($terms as $term) {
|
foreach($terms as $term) {
|
||||||
$query = $query->orWhereRaw(
|
$query->orWhereMultipleColumns([
|
||||||
$this->buildMultipleColumnSearch([
|
DB::getTablePrefix() . 'users.first_name',
|
||||||
DB::getTablePrefix() . 'users.first_name',
|
DB::getTablePrefix() . 'users.last_name',
|
||||||
DB::getTablePrefix() . 'users.last_name',
|
], $term);
|
||||||
]),
|
|
||||||
["%{$term}%"]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
|
|
Loading…
Reference in a new issue