mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
adds user location scope, still needs fine tuning
This commit is contained in:
parent
442cad69a7
commit
57019e170f
|
@ -21,6 +21,7 @@ use Illuminate\Http\Request;
|
|||
use App\Http\Requests\ImageUploadRequest;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
|
@ -185,7 +186,9 @@ class UsersController extends Controller
|
|||
$users->where('autoassign_licenses', '=', $request->input('autoassign_licenses'));
|
||||
}
|
||||
|
||||
if ($request->filled('search')) {
|
||||
if ($request->filled('location_id') != '') {
|
||||
$users = $users->UserLocation($request->input('location_id'), $request->input('search'));
|
||||
} else {
|
||||
$users = $users->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
|
@ -530,7 +533,7 @@ class UsersController extends Controller
|
|||
try {
|
||||
Storage::disk('public')->delete('avatars/'.$user->avatar);
|
||||
} catch (\Exception $e) {
|
||||
\Log::debug($e);
|
||||
Log::debug($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -787,5 +787,22 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function scopeUserLocation($query, $location, $search){
|
||||
|
||||
|
||||
return $query->where('location_id','=', $location)
|
||||
->where('first_name', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('email', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('first_name', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('permissions', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('country', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('phone', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('jobtitle', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('employee_num', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('username', 'LIKE', '%' . $search . '%');
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue