Added option to adjust visible button count on edit link page

This commit is contained in:
Julian Prieber 2022-08-05 17:29:49 +02:00
parent baeca4acef
commit 33fd0f7e10
3 changed files with 44 additions and 1 deletions

View File

@ -170,6 +170,33 @@ class UserController extends Controller
return view('studio/links', $data);
}
//Show link, 20
public function showLinks20()
{
$userId = Auth::user()->id;
$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);
return view('studio/links', $data);
}
//Show link, 30
public function showLinks30()
{
$userId = Auth::user()->id;
$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);
return view('studio/links', $data);
}
//Show link, all
public function showLinksAll()
{
$userId = Auth::user()->id;
$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);
return view('studio/links', $data);
}
//Delete link
public function deleteLink(request $request)
{

View File

@ -2,8 +2,19 @@
@section('content')
@if(Request::is('studio/links/10'))
@php setcookie("LinkCount", "10", time()+60*60*24*5, "/"); @endphp
@elseif(Request::is('studio/links/20'))
@php setcookie("LinkCount", "20", time()+60*60*24*5, "/"); @endphp
@elseif(Request::is('studio/links/30'))
@php setcookie("LinkCount", "30", time()+60*60*24*5, "/"); @endphp
@elseif(Request::is('studio/links/all'))
@php setcookie("LinkCount", "all", time()+60*60*24*5, "/"); @endphp
@endif
<h2 class="mb-4"><i class="bi bi-link-45deg"> Links</i></h2>
<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>
<div style="overflow-y: auto;">
<table class="table table-bordered">
<thead>

View File

@ -68,10 +68,15 @@ Route::group([
'middleware' => env('REGISTER_AUTH'),
], function () {
if(env('FORCE_HTTPS') == 'true'){URL::forceScheme('https');}
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
Route::get('/studio/index', [UserController::class, 'index'])->name('studioIndex');
Route::get('/studio/add-link', [UserController::class, 'showButtons'])->name('showButtons');
Route::post('/studio/add-link', [UserController::class, 'addLink'])->name('addLink');
Route::get('/studio/links', [UserController::class, 'showLinks'])->name('showLinks');
Route::get('/studio/links', [UserController::class, $LinkPage])->name($LinkPage);
Route::get('/studio/links/10', [UserController::class, 'showLinks'])->name('showLinks');
Route::get('/studio/links/20', [UserController::class, 'showLinks20'])->name('showLinks20');
Route::get('/studio/links/30', [UserController::class, 'showLinks30'])->name('showLinks30');
Route::get('/studio/links/all', [UserController::class, 'showLinksAll'])->name('showLinksAll');
Route::get('/studio/theme', [UserController::class, 'showTheme'])->name('showTheme');
Route::post('/studio/theme', [UserController::class, 'editTheme'])->name('editTheme');
Route::get('/deleteLink/{id}', [UserController::class, 'deleteLink'])->name('deleteLink');