Skip to content

Commit bdb293c

Browse files
committed
Added option to clear icon chache
1 parent 40964d9 commit bdb293c

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

app/Http/Controllers/UserController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,23 @@ public function deleteLink(request $request)
402402
return redirect('/studio/links');
403403
}
404404

405+
//Delete icon
406+
public function clearIcon(request $request)
407+
{
408+
$linkId = $request->id;
409+
410+
$directory = base_path("studio/favicon/icons");
411+
$files = scandir($directory);
412+
foreach($files as $file) {
413+
if (strpos($file, $linkId.".") !== false) {
414+
$pathinfo = pathinfo($file, PATHINFO_EXTENSION);}}
415+
if (isset($pathinfo)) {
416+
try{File::delete(base_path("studio/favicon/icons")."/".$linkId.".".$pathinfo);} catch (exception $e) {}
417+
}
418+
419+
return redirect('/studio/links');
420+
}
421+
405422
//Raise link on the littlelink page
406423
public function upLink(request $request)
407424
{

resources/views/studio/links.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@
122122

123123
@endif
124124

125-
<a href="{{ route('deleteLink', $link->id ) }}" onclick="return confirm('Are you sure you want to delete `{{$link->title}}` ?')" class="float-right hvr-grow p-1 text-danger"><i class='bi bi-trash'></i></a>
125+
<a href="{{ route('deleteLink', $link->id ) }}" title="Delete" onclick="return confirm('Are you sure you want to delete `{{$link->title}}` ?')" class="float-right hvr-grow p-1 text-danger"><i class='bi bi-trash'></i></a>
126+
127+
<a href="{{ route('clearIcon', $link->id ) }}" title="Clear icon cache" class="float-right hvr-grow p-1 text-primary"><i style="-webkit-text-stroke:1px;padding-right:5px;" class="bi bi-arrow-repeat"></i></a>
126128

127129

128130

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
Route::get('/studio/theme', [UserController::class, 'showTheme'])->name('showTheme');
102102
Route::post('/studio/theme', [UserController::class, 'editTheme'])->name('editTheme');
103103
Route::get('/deleteLink/{id}', [UserController::class, 'deleteLink'])->name('deleteLink');
104+
Route::get('/clearIcon/{id}', [UserController::class, 'clearIcon'])->name('clearIcon');
104105
Route::get('/upLink/{up}/{id}', [UserController::class, 'upLink'])->name('upLink');
105106
Route::post('/studio/edit-link/{id}', [UserController::class, 'editLink'])->name('editLink');
106107
Route::get('/studio/button-editor/{id}', [UserController::class, 'showCSS'])->name('showCSS');

0 commit comments

Comments
 (0)