Sorted buttons alphabetically

This commit is contained in:
Julian Prieber 2022-08-02 00:33:32 +02:00
parent 388d2f27b8
commit e4f77996e2
2 changed files with 13 additions and 2 deletions

View File

@ -209,7 +209,8 @@ class UserController extends Controller
$buttonId = Link::where('id', $linkId)->value('button_id');
$buttonName = Button::where('id', $buttonId)->value('name');
$buttons = Button::select('id', 'name')->get();
$buttons = Button::select('id', 'name')->orderBy('name', 'asc')->get();
return view('studio/edit-link', ['custom_css' => $custom_css, 'buttonId' => $buttonId, 'buttons' => $buttons, 'link' => $link, 'title' => $title, 'order' => $order, 'id' => $linkId , 'buttonName' => $buttonName]);

View File

@ -17,11 +17,21 @@
<div class="form-group col-lg-8">
<label for="exampleFormControlSelect1">Button</label>
<select class="form-control" name="button">
<option> {{ $buttonName }} </option>
<option style="background-color:#1e90ff;color:#fff"> {{ $buttonName }} </option>
@foreach($buttons as $button)
@if ($button->name != "custom")@if ($loop->first)<option style="background-color:#ffe8e4;"> custom </option>@endif @endif
@if ($button->name != "custom_website")@if ($loop->first)<option style="background-color:#ffe8e4;"> custom_website </option>@endif @endif
@endforeach
@foreach($buttons as $button)
@if (!in_array($button->name, ['custom', 'custom_website', 'heading', 'space']))
@if ($button->name != $buttonName)
<option> {{ $button->name }} </option>
@endif
@endif
@endforeach
@foreach($buttons as $button)
@if ($button->name != "heading")@if ($loop->first)<option style="background-color:#ebebeb;"> heading </option>@endif @endif
@if ($button->name != "space")@if ($loop->first)<option style="background-color:#ebebeb;"> space </option>@endif @endif
@endforeach
</select>
</div>