diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index e13f7c1..6b7a8fd 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -698,4 +698,70 @@ class UserController extends Controller return redirect('/'); } + + //Edit/save page icons + public function editIcons(request $request) + { + + function searchIcon($icon) + { + $iconId = DB::table('links') + ->where('user_id', Auth::id()) + ->where('title', $icon) + ->where('button_id', 94) + ->value('id'); + + if (is_null($iconId)){ + return false; + } else { + return $iconId; + } + } + + function addIcon($icon, $link){ + $links = new Link; + $links->user_id = Auth::id(); + $links->button_id = '94'; + $links->link = $link; + $links->title = $icon; + $links->save(); + } + + function updateIcon($icon, $link){ + Link::where('id', searchIcon($icon))->update([ + 'button_id' => 94, + 'link' => $link, + 'title' => $icon + ]); + } + + function saveIcon($icon, $link){ + if(isset($link)){ + if(searchIcon($icon) != NULL){ + updateIcon($icon, $link); + }else{ + addIcon($icon, $link);} + } +} + + + + + saveIcon('mastodon', $request->mastodon); + + saveIcon('instagram', $request->instagram); + + saveIcon('twitter', $request->twitter); + + saveIcon('github', $request->github); + + saveIcon('linkedin', $request->linkedin); + + + + + return Redirect('studio/links#icons'); + + } + } \ No newline at end of file diff --git a/resources/views/littlelink.blade.php b/resources/views/littlelink.blade.php index 671b7d6..6cf1c2e 100644 --- a/resources/views/littlelink.blade.php +++ b/resources/views/littlelink.blade.php @@ -258,15 +258,27 @@ function get_operating_system() {

{{ $info->name }}

-

@if(env('ALLOW_USER_HTML') === true){!! $info->littlelink_description !!}@else{{ $info->littlelink_description }}@endif

+

@if(env('ALLOW_USER_HTML') === true){!! $info->littlelink_description !!}@else{{ $info->littlelink_description }}@endif

+ + + @php $icons = DB::table('links')->where('user_id', 1)->where('button_id', 94)->get(); @endphp +
+ @foreach($icons as $icon) + + @endforeach +
+ + + @endforeach @foreach($links as $link) @php $linkName = str_replace('default ','',$link->name) @endphp - @if($link->button_id === 0) + @if($link->name === "icon") + @elseif($link->button_id === 0)
{{ $link->title }}
@elseif($link->name === "phone")
button-icon{{ $link->title }}
diff --git a/resources/views/studio/links.blade.php b/resources/views/studio/links.blade.php index 3c6e141..8ad8233 100755 --- a/resources/views/studio/links.blade.php +++ b/resources/views/studio/links.blade.php @@ -15,6 +15,8 @@ @endif @push('sidebar-stylesheets') + + + @endpush @include('components.favicon') @@ -55,6 +58,8 @@ @@ -160,13 +164,73 @@
-
+

Preview:

+

+ +
+ +

Page Icons

+
+ +
+ @csrf +
+ + @php + function iconLink($icon){ + $iconLink = DB::table('links') + ->where('user_id', Auth::id()) + ->where('title', $icon) + ->where('button_id', 94) + ->value('link'); + if (is_null($iconLink)){ + return false; + } else { + return $iconLink;}} + function searchIcon($icon) + {$iconId = DB::table('links') + ->where('user_id', Auth::id()) + ->where('title', $icon) + ->where('button_id', 94) + ->value('id'); + if(is_null($iconId)){return false;}else{return $iconId;}} + + function icon($name, $label){ echo ' + +
+
+
+
+ '; + if(searchIcon($name) != NULL){echo '';} + echo '

';} + @endphp + + + + {!!icon('mastodon', 'Mastodon')!!} + + {!!icon('instagram', 'Instagram')!!} + + {!!icon('twitter', 'Twitter')!!} + + {!!icon('github', 'GitHub')!!} + + {!!icon('linkedin', 'LinkedIn')!!} + + + + + + +
+