@php $librariesToInclude = []; @endphp @foreach($links as $link) @if(isset($link->custom_html) && isset($link->include_libraries) && $link->custom_html && is_array($link->include_libraries)) @foreach($link->include_libraries as $library => $include) @if($include) @php $librariesToInclude[$library] = true; @endphp @endif @endforeach @endif @endforeach @foreach($librariesToInclude as $library => $include) @switch($library) @case('jquery') @once @push('linkstack-head') @endpush @endonce @break @case('sweetalert') @once @push('linkstack-head') @endpush @endonce @break @endswitch @endforeach @php /* For debugging purposes, you can add a script to the end of the body that logs the inclusion of each library: */ @endphp {{-- @push('linkstack-body-end') @endpush --}}