invite tree admin panel
This commit is contained in:
parent
a518693003
commit
cc86e366fa
|
|
@ -16,7 +16,7 @@ class AdminController extends Controller
|
|||
public function users(Request $request)
|
||||
{
|
||||
if ($request->searchBy == 'name' && $request->has('q')) {
|
||||
$users = DB::table('users')->where('name', 'LIKE', '%'.$request->q.'%')->paginate(10);
|
||||
$users = DB::table('users')->where('name', 'LIKE', '%' . $request->q . '%')->paginate(10);
|
||||
} else if ($request->searchBy == 'id' && $request->has('q')) {
|
||||
$users = DB::table('users')->where('id', $request->q)->paginate(10);
|
||||
} else {
|
||||
|
|
@ -26,8 +26,30 @@ class AdminController extends Controller
|
|||
return view('admin.users')->with('users', $users);
|
||||
}
|
||||
|
||||
public function keys()
|
||||
public function tree(Request $request)
|
||||
{
|
||||
return view('admin.keys');
|
||||
if ($request->searchBy == 'name' && $request->has('q')) {
|
||||
$user = DB::table('users')->where('name', $request->q)->first();
|
||||
} else if ($request->searchBy == 'id' && $request->has('q')) {
|
||||
$user = DB::table('users')->where('id', $request->q)->first();
|
||||
} else {
|
||||
$user = array();
|
||||
}
|
||||
|
||||
if (empty($user)) {
|
||||
$children = null;
|
||||
$invited_by = null;
|
||||
} else {
|
||||
$children = User::where('invited_by', $user->id)->get();
|
||||
$invited_by = User::find($user->invited_by)->name;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'children' => $children,
|
||||
'invited_by' => $invited_by,
|
||||
];
|
||||
|
||||
return view('admin.tree')->with('data', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
@extends('layouts.admin')
|
||||
@section('title')
|
||||
<title>
|
||||
Admin | Invite Tree - {{ env('APP_NAME') }}</title>
|
||||
<style>
|
||||
.flex {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#SearchContainer a {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div id="UserList">
|
||||
<h2>Invite Tree</h2>
|
||||
@if (request()->query('q'))
|
||||
<a href="{{ route('admin_tree') }}" style="color:navy">Clear Search</a>
|
||||
@endif
|
||||
|
||||
<form method="GET" action="{{ route('admin_tree') }}">
|
||||
<div style="margin-top:10px;margin-bottom:10px;"><input type="text" id="q" name="q"
|
||||
placeholder="Search..." value="{{ request()->q }}"><button class="bluebutton" style="margin-left:2px"
|
||||
name="searchBy" value="name">Search by Username</button><button class="bluebutton"
|
||||
style="margin-left:2px" name="searchBy" value="id">Search by ID</button></div>
|
||||
</form>
|
||||
@if ($data['user'])
|
||||
<div id="SearchContainer">
|
||||
<ul>
|
||||
<li>
|
||||
<h3><a
|
||||
href="{{ route('profile', App\Models\User::where('name', $data['invited_by'])->first()->id) }}">{{ $data['invited_by'] }}</a>
|
||||
</h3>
|
||||
</li>
|
||||
<ul>
|
||||
<li><a href="{{ route('profile', $data['user']->id) }}">{{ $data['user']->name }}</a></li>
|
||||
<ul>
|
||||
@foreach ($data['children'] as $child)
|
||||
<li><a href="{{ route('profile', $child->id) }}">{{ $child->name }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@if (!request()->has('q'))
|
||||
<h5>Enter a username or ID.</h5>
|
||||
@elseif (!$data['user'])
|
||||
<h5>No user was found, check if you entered the correct details.</h5>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
<br>
|
||||
<a href="{{ route('admin_users') }}">User List</a>
|
||||
<br>
|
||||
<a>Invite Tree</a>
|
||||
<a href="{{ route('admin_tree') }}">Invite Tree</a>
|
||||
<br><br>
|
||||
<a href="{{ route('home') }}"><span style="font-size:20px">←</span> Return to Main Site</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Route::middleware(['auth'])->group(function () {
|
|||
Route::group(['middleware' => 'AdminCheck'], function() {
|
||||
Route::get('/iphone/dashboard', [App\Http\Controllers\AdminController::class, 'index'])->name('admin_index');
|
||||
Route::get('/iphone/users', [App\Http\Controllers\AdminController::class, 'users'])->name('admin_users');
|
||||
Route::get('/iphone/keys', [App\Http\Controllers\AdminController::class, 'keys'])->name('admin_keys');
|
||||
Route::get('/iphone/tree', [App\Http\Controllers\AdminController::class, 'tree'])->name('admin_tree');
|
||||
});
|
||||
|
||||
// Client routes
|
||||
|
|
|
|||
Loading…
Reference in New Issue