Skip to content

Commit 2dc3e3d

Browse files
committed
Added option for admins to view and delete user links
1 parent dfe0a03 commit 2dc3e3d

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ public function showUser(request $request)
9494

9595
}
9696

97+
//Show link, click number, up link in links page
98+
public function showLinksUser(request $request)
99+
{
100+
$id = $request->id;
101+
102+
$data['user'] = User::where('id', $id)->get();
103+
104+
$data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(10);
105+
return view('panel/links', $data);
106+
}
107+
108+
//Delete link
109+
public function deleteLinkUser(request $request)
110+
{
111+
$linkId = $request->id;
112+
113+
Link::where('id', $linkId)->delete();
114+
115+
return back();
116+
}
117+
97118
//Save user edit
98119
public function editUser(request $request)
99120
{
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@extends('layouts.sidebar')
2+
3+
@section('content')
4+
5+
<h2 class="mb-4"><i class="bi bi-link-45deg"> Links</i></h2>
6+
7+
<div style="overflow-y: auto;">
8+
<table class="table table-bordered">
9+
<thead>
10+
<tr>
11+
<th scope="col">Link</th>
12+
<th scope="col">Title</th>
13+
<th scope="col">Click</th>
14+
<th scope="col">Delete</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
@foreach($links as $link)
19+
<tr>
20+
<td title="{{ $link->link }}">{{ Str::limit($link->link, 30) }}</td>
21+
<td title="{{ $link->title }}">{{ Str::limit($link->title, 30) }}</td>
22+
<td class="text-right">{{ $link->click_number }}</td>
23+
<td><a href="{{ route('deleteLinkUser', $link->id ) }}" class="text-danger">Delete</a></td>
24+
</tr>
25+
@endforeach
26+
</tbody>
27+
</table>
28+
</div>
29+
30+
<ul class="pagination justify-content-center">
31+
{!! $links ?? ''->links() !!}
32+
</ul>
33+
34+
<a class="btn btn-primary" href="{{ url('/panel/users/all') }}">⬅ Back</a>
35+
36+
@endsection

resources/views/panel/users.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<th scope="col">Page</th>
2525
<th scope="col">Role</th>
2626
<th scope="col">Edit</th>
27+
<th scope="col">Buttons</th>
2728
<th scope="col">Block</th>
2829
</tr>
2930
</thead>
@@ -34,6 +35,7 @@
3435
<td><a href="{{ url('') }}/@<?= $user->littlelink_name ?>" target="_blank" class="text-info"><i class="bi bi-box-arrow-up-right"></i>&nbsp; {{ $user->littlelink_name }} </a></td>
3536
<td>{{ $user->role }}</td>
3637
<td><a href="{{ route('editUser', $user->id ) }}">Edit</a></td>
38+
<td><a href="{{ route('showLinksUser', $user->id ) }}">View</a></td>
3739
<td><a href="{{ route('blockUser', ['block' => $user->block, 'id' => $user->id] ) }}" class="text-danger">{{ $user->block }}</a></td>
3840
</tr>
3941
@endforeach

routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
Route::get('/panel/index', [AdminController::class, 'index'])->name('panelIndex');
7474
Route::get('/panel/users/{type}', [AdminController::class, 'users'])->name('showUsers');
7575
Route::post('/panel/users/{name?}', [AdminController::class, 'searchUser'])->name('searchUser');
76+
Route::get('/panel/links/{id}', [AdminController::class, 'showLinksUser'])->name('showLinksUser');
77+
Route::get('/panel/deleteLink/{id}', [AdminController::class, 'deleteLinkUser'])->name('deleteLinkUser');
7678
Route::get('/panel/users/block/{block}/{id}', [AdminController::class, 'blockUser'])->name('blockUser');
7779
Route::get('/panel/edit-user/{id}', [AdminController::class, 'showUser'])->name('showUser');
7880
Route::post('/panel/edit-user/{id}', [AdminController::class, 'editUser'])->name('editUser');

0 commit comments

Comments
 (0)