Skip to content

Commit 33fd0f7

Browse files
committed
Added option to adjust visible button count on edit link page
1 parent baeca4a commit 33fd0f7

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

app/Http/Controllers/UserController.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,33 @@ public function showLinks()
170170
return view('studio/links', $data);
171171
}
172172

173+
//Show link, 20
174+
public function showLinks20()
175+
{
176+
$userId = Auth::user()->id;
177+
178+
$data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $userId)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(20);
179+
return view('studio/links', $data);
180+
}
181+
182+
//Show link, 30
183+
public function showLinks30()
184+
{
185+
$userId = Auth::user()->id;
186+
187+
$data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $userId)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(30);
188+
return view('studio/links', $data);
189+
}
190+
191+
//Show link, all
192+
public function showLinksAll()
193+
{
194+
$userId = Auth::user()->id;
195+
196+
$data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $userId)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(10000000000);
197+
return view('studio/links', $data);
198+
}
199+
173200
//Delete link
174201
public function deleteLink(request $request)
175202
{

resources/views/studio/links.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22

33
@section('content')
44

5+
@if(Request::is('studio/links/10'))
6+
@php setcookie("LinkCount", "10", time()+60*60*24*5, "/"); @endphp
7+
@elseif(Request::is('studio/links/20'))
8+
@php setcookie("LinkCount", "20", time()+60*60*24*5, "/"); @endphp
9+
@elseif(Request::is('studio/links/30'))
10+
@php setcookie("LinkCount", "30", time()+60*60*24*5, "/"); @endphp
11+
@elseif(Request::is('studio/links/all'))
12+
@php setcookie("LinkCount", "all", time()+60*60*24*5, "/"); @endphp
13+
@endif
14+
515
<h2 class="mb-4"><i class="bi bi-link-45deg"> Links</i></h2>
616

17+
<div style="text-align: right;"><a href="{{ url('/studio/links') }}/10">10</a> | <a href="{{ url('/studio/links') }}/20">20</a> | <a href="{{ url('/studio/links') }}/30">30</a> | <a href="{{ url('/studio/links') }}/all">all</a></div>
718
<div style="overflow-y: auto;">
819
<table class="table table-bordered">
920
<thead>

routes/web.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@
6868
'middleware' => env('REGISTER_AUTH'),
6969
], function () {
7070
if(env('FORCE_HTTPS') == 'true'){URL::forceScheme('https');}
71+
if(isset($_COOKIE['LinkCount'])){if($_COOKIE['LinkCount'] == '20'){$LinkPage = 'showLinks20';}elseif($_COOKIE['LinkCount'] == '30'){$LinkPage = 'showLinks30';}elseif($_COOKIE['LinkCount'] == 'all'){$LinkPage = 'showLinksAll';} else {$LinkPage = 'showLinks';}} else {$LinkPage = 'showLinks';} //Shows correct link number
7172
Route::get('/studio/index', [UserController::class, 'index'])->name('studioIndex');
7273
Route::get('/studio/add-link', [UserController::class, 'showButtons'])->name('showButtons');
7374
Route::post('/studio/add-link', [UserController::class, 'addLink'])->name('addLink');
74-
Route::get('/studio/links', [UserController::class, 'showLinks'])->name('showLinks');
75+
Route::get('/studio/links', [UserController::class, $LinkPage])->name($LinkPage);
76+
Route::get('/studio/links/10', [UserController::class, 'showLinks'])->name('showLinks');
77+
Route::get('/studio/links/20', [UserController::class, 'showLinks20'])->name('showLinks20');
78+
Route::get('/studio/links/30', [UserController::class, 'showLinks30'])->name('showLinks30');
79+
Route::get('/studio/links/all', [UserController::class, 'showLinksAll'])->name('showLinksAll');
7580
Route::get('/studio/theme', [UserController::class, 'showTheme'])->name('showTheme');
7681
Route::post('/studio/theme', [UserController::class, 'editTheme'])->name('editTheme');
7782
Route::get('/deleteLink/{id}', [UserController::class, 'deleteLink'])->name('deleteLink');

0 commit comments

Comments
 (0)