From c0a8c4150bebe96bb0c2684ffe1a9834305adc87 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Sun, 10 Apr 2022 17:42:29 +0200 Subject: [PATCH] Added controller for button editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added controller to display and edit custom CSS for the upcoming button editor. See: https://blog.littlelink-custom.com/upcoming-features/ --- app/Http/Controllers/UserController.php | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9da128e..128120c 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -201,6 +201,23 @@ class UserController extends Controller } + //Show custom CSS + public function showCSS(request $request) + { + $linkId = $request->id; + + $link = Link::where('id', $linkId)->value('link'); + $title = Link::where('id', $linkId)->value('title'); + $order = Link::where('id', $linkId)->value('order'); + $custom_css = Link::where('id', $linkId)->value('custom_css'); + $buttonId = Link::where('id', $linkId)->value('button_id'); + + $buttons = Button::select('id', 'name')->get(); + + return view('studio/button-editor', ['custom_css' => $custom_css, 'buttonId' => $buttonId, 'buttons' => $buttons, 'link' => $link, 'title' => $title, 'order' => $order, 'id' => $linkId]); + + } + //Save edit link public function editLink(request $request) { @@ -232,6 +249,21 @@ class UserController extends Controller return redirect('/studio/links'); } + //Save edit custom CSS + public function editCSS(request $request) + { + $request->validate([ + 'custom_css' => 'required', + ]); + + $linkId = $request->id; + $custom_css = $request->custom_css; + + Link::where('id', $linkId)->update(['custom_css' => $custom_css]); + + return header("Refresh:0"); + } + //Show littlelinke page for edit public function showPage(request $request) {