mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 05:47:28 -08:00
* Search functionality in accessories/{accessory} issue #5471: From the collection of users displayed just filtered the data with the method where() and concat() for the user can search for first name or last name. The solution is case sensitive. * A better fix to issue #5471. Now using the established relationship to querying for the users. Also Case-insensitive. * Fixed previous commit that has magic number in the find method parameter of AccessoriesController.
This commit is contained in:
parent
05b03df600
commit
b692f67779
|
@ -143,13 +143,16 @@ class AccessoriesController extends Controller
|
|||
|
||||
$accessory->lastCheckoutArray = $accessory->lastCheckout->toArray();
|
||||
$accessory_users = $accessory->users;
|
||||
|
||||
if($request->filled('search')){
|
||||
$accessory_users = $accessory_users->where('first_name', $request->input('search'))->concat($accessory_users->where('last_name', $request->input('search')));
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$accessory_users = $accessory->users()
|
||||
->where('first_name', 'like', '%'.$request->input('search').'%')
|
||||
->orWhere('last_name', 'like', '%'.$request->input('search').'%')
|
||||
->get();
|
||||
}
|
||||
|
||||
$total = $accessory_users->count();
|
||||
|
||||
|
||||
return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $accessory_users, $total);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue