mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-05-07 05:53:07 +00:00
Add Accounts search feature in admin panel
This commit is contained in:
parent
f98df3f830
commit
e889c5f9ef
4 changed files with 38 additions and 12 deletions
|
|
@ -10,13 +10,25 @@ use App\Admin;
|
|||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
public function index(Request $request, $search = '')
|
||||
{
|
||||
$accounts = Account::orderBy('creation_time', 'desc');
|
||||
|
||||
if (!empty($search)) {
|
||||
$accounts = $accounts->where('username', 'like', '%'.$search.'%');
|
||||
}
|
||||
|
||||
return view('admin.account.index', [
|
||||
'accounts' => Account::orderBy('creation_time', 'desc')->paginate(30)
|
||||
'search' => $search,
|
||||
'accounts' => $accounts->paginate(30)->appends($request->query())
|
||||
]);
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
return redirect()->route('admin.account.index', $request->get('search'));
|
||||
}
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
return view('admin.account.show', [
|
||||
|
|
|
|||
|
|
@ -36,13 +36,9 @@
|
|||
<div class="list-group">
|
||||
<a href="{{ route('admin.account.index') }}" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">Change my current account email</h5>
|
||||
<h5 class="mb-1">Accounts</h5>
|
||||
</div>
|
||||
@if (!empty($account->email))
|
||||
<p class="mb-1">{{ $account->email }}</p>
|
||||
@else
|
||||
<p class="mb-1">No email yet</p>
|
||||
@endif
|
||||
<p class="mb-1">Manage the FlexiSIP accounts</p>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -6,9 +6,26 @@
|
|||
|
||||
@section('content')
|
||||
|
||||
<h2>Accounts</h2>
|
||||
<div class="row mb-2">
|
||||
<div class="col-6">
|
||||
<h2>Accounts</h2>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{!! Form::open(['route' => 'admin.account.search']) !!}
|
||||
<div class="form-row">
|
||||
<div class="col-9">
|
||||
{!! Form::text('search', $search, ['class' => 'form-control', 'placeholder' => 'Search by username: +1234, foo_bar…']) !!}
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
|
||||
<table class="table table-responsive-md">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
});
|
||||
|
||||
Route::group(['middleware' => 'auth.admin'], function () {
|
||||
Route::get('admin/accounts', 'Admin\AccountController@index')->name('admin.account.index');
|
||||
Route::get('admin/accounts/{id}', 'Admin\AccountController@show')->name('admin.account.show');
|
||||
Route::get('admin/accounts/{search?}', 'Admin\AccountController@index')->name('admin.account.index');
|
||||
Route::post('admin/search', 'Admin\AccountController@search')->name('admin.account.search');
|
||||
Route::get('admin/accounts/show/{id}', 'Admin\AccountController@show')->name('admin.account.show');
|
||||
Route::get('admin/accounts/{id}/activate', 'Admin\AccountController@activate')->name('admin.account.activate');
|
||||
Route::get('admin/accounts/{id}/deactivate', 'Admin\AccountController@deactivate')->name('admin.account.deactivate');
|
||||
Route::get('admin/accounts/{id}/admin', 'Admin\AccountController@admin')->name('admin.account.admin');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue