mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#2386 admin advs list - user select2 make it ajax
This commit is contained in:
parent
4ab6ac1ca6
commit
066a27e9a5
@ -151,7 +151,25 @@ $(document).ready(function () {
|
||||
|
||||
// User filter
|
||||
$("select[name=filter_User]").select2({
|
||||
placeholder: $('select[name=filter_User] option:first-child').text()
|
||||
placeholder: $('select[name=filter_User] option:first-child').text(),
|
||||
ajax: {
|
||||
url: '/api/profile/query-users',
|
||||
dataType: 'json',
|
||||
processResults: function (data) {
|
||||
let formattedData = [];
|
||||
|
||||
Object.keys(data).forEach(function (id) {
|
||||
formattedData.push({
|
||||
'id': id,
|
||||
'text': data[id]
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
results: formattedData
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Country filter
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
|
||||
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Visiosoft\ProfileModule\Profile\UsersExport;
|
||||
|
||||
@ -10,4 +12,18 @@ class UsersController extends AdminController
|
||||
{
|
||||
return Excel::download(new UsersExport(), 'users-' . time() . '.csv');
|
||||
}
|
||||
|
||||
public function queryUsers(UserRepositoryInterface $userRepository)
|
||||
{
|
||||
$term = request()->term;
|
||||
if ($term) {
|
||||
return $userRepository->newQuery()
|
||||
->select(DB::raw("CONCAT_WS('', first_name, ' ', last_name, ' (', gsm_phone, ' || ', email, ')') AS name"), 'id')
|
||||
->where('first_name', 'LIKE', "%$term%")
|
||||
->orWhere('last_name', 'LIKE', "%$term%")
|
||||
->orWhere('gsm_phone', 'LIKE', "%$term%")
|
||||
->limit(5)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
'as' => 'users::exportUsers',
|
||||
'uses' => 'Visiosoft\ProfileModule\Http\Controller\Admin\UsersController@exportUsers'
|
||||
],
|
||||
'api/profile/query-users' => 'Visiosoft\ProfileModule\Http\Controller\Admin\UsersController@queryUsers',
|
||||
|
||||
// MyProfileController
|
||||
'profile/ads' => [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user