routes update
This commit is contained in:
@@ -66,42 +66,43 @@ class AdminController extends Controller
|
||||
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
public function displayUsers($page) {
|
||||
public function searchUsers(Request $request) {
|
||||
//Declare array variables
|
||||
$user = array();
|
||||
$permission = array();
|
||||
$userArr = array();
|
||||
$permString = null;
|
||||
|
||||
/**
|
||||
* For each user we want to build their name and permission set into one array
|
||||
* Having all of the data in one array will allow us to build the table for the admin page more fluently.
|
||||
* Example: userArr[0]['name'] = Minerva Arbosa
|
||||
* userArr[0]['role'] = W4RP
|
||||
* userArr[0]['permissions'] = ['admin', 'contract.admin', superuser]
|
||||
*/
|
||||
$usersTable = User::orderBy('name', 'asc')->get()->toArray();
|
||||
foreach($usersTable as $user) {
|
||||
//Validate the input from the form
|
||||
$this->validate($request, [
|
||||
'parameter' => 'required',
|
||||
]);
|
||||
|
||||
$usersArr = User::where('name', 'like', $request->parameter)->paginate(50);
|
||||
|
||||
foreach($usersArr as $user) {
|
||||
$user->role = $user->getRole();
|
||||
|
||||
$permCount = UserPermission::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->count();
|
||||
|
||||
if($permCount > 0) {
|
||||
$perms = UserPermission::where([
|
||||
'character_id' => $user['character_id'],
|
||||
'character_id' => $user->character_id,
|
||||
])->get('permission')->toArray();
|
||||
|
||||
$tempUser['name'] = $user['name'];
|
||||
$tempUser['role'] = $user['user_type'];
|
||||
$tempUser['permissions'] = $perms;
|
||||
|
||||
array_push($userArr, $tempUser);
|
||||
foreach($perms as $perm) {
|
||||
$permString .= $perm['permission'] . ', ';
|
||||
}
|
||||
|
||||
//Get a user count for the view so we can do pagination
|
||||
$userCount = User::orderBy('name', 'asc')->count();
|
||||
//Set the amount of pages for the data
|
||||
$userPages = ceil($userCount / 50);
|
||||
$users = User::pluck('name')->all();
|
||||
$user->permission = $permString;
|
||||
} else {
|
||||
$user->permission = 'No Permissions';
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.dashboards.users')->with('users', $users)
|
||||
->with('userArr', $userArr)
|
||||
->with('userCount', $userCount)
|
||||
->with('userPages', $userPages);
|
||||
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
||||
}
|
||||
|
||||
public function displayAllowedLogins() {
|
||||
|
||||
4
resources/views/admin/dashboards/dashboard.blade.php
Normal file
4
resources/views/admin/dashboards/dashboard.blade.php
Normal file
@@ -0,0 +1,4 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
|
||||
@endsection
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
User Information
|
||||
<h2>User Information</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
@@ -14,26 +14,18 @@
|
||||
<th>Action</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($userArr as $user)
|
||||
@foreach($usersArr as $user)
|
||||
<tr>
|
||||
<td>{{ $user['name'] }}</td>
|
||||
<td>{{ $user['role'] }}</td>
|
||||
<td>
|
||||
@if($user['permissions'])
|
||||
@foreach($user['permissions'] as $perm)
|
||||
{{ implode(', ', $perm) }}
|
||||
@endforeach
|
||||
@else
|
||||
No Permissions
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $user->name }}</td>
|
||||
<td>{{ $user->role }}</td>
|
||||
<td>{{ $user->permission }}</td>
|
||||
<td>
|
||||
{!! Form::open(['action' => 'Dashboard\AdminController@displayModifyUser', 'method' => 'POST']) !!}
|
||||
{{ Form::hidden('user', $user['name']) }}
|
||||
{{ Form::hidden('user', $user->name) }}
|
||||
{{ Form::submit('Modify User', ['class' => 'btn btn-primary']) }}
|
||||
{!! Form::close() !!}
|
||||
{!! Form::open(['action' => 'Dashboard\AdminController@removeUser', 'method' => 'POST']) !!}
|
||||
{{ Form::hidden('user', $user['name']) }}
|
||||
{{ Form::hidden('user', $user->name) }}
|
||||
{{ Form::submit('Remove User', ['class' => 'btn btn-danger']) }}
|
||||
{!! Form::close() !!}
|
||||
</td>
|
||||
@@ -6,6 +6,15 @@
|
||||
<h2>User Information</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="container">
|
||||
{!! Form::open(['action' => 'Dashboard\AdminController@searchUsers', 'method' => 'POST']) !!}
|
||||
<div class="form-group">
|
||||
{{ Form::label('parameter', 'Seach For A User') }}
|
||||
{{ Form::text('parameter', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }}
|
||||
</div>
|
||||
{{ Form::submit('Search', ['class' => 'btn btn-primary']) }}
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
|
||||
@@ -24,6 +24,7 @@ Route::group(['middleware' => ['auth']], function(){
|
||||
* Admin Controller display pages
|
||||
*/
|
||||
Route::get('/admin/dashboard/users', 'Dashboard\AdminController@displayUsersPaginated');
|
||||
Route::post('/admin/dashboard/users', 'Dashboard\AdminController@searchUsers');
|
||||
Route::get('/admin/dashboard/taxes', 'Dashboard\AdminController@displayTaxes');
|
||||
Route::get('/admin/dashboard/logins', 'Dashboard\AdminController@displayAllowedLogins');
|
||||
Route::get('/admin/dashboard/purgewiki', 'Dashboard\AdminController@displayPurgeWiki');
|
||||
|
||||
Reference in New Issue
Block a user