I am trying to create a HTML widget with Laravel blade similar to the following (widget.blade.php):
@push('scripts')
<script src="{{ asset('js/foo.js') }}"></script>
<script>
...
</script>
@endpush
@push('styles')
<link href="{{ asset('css/bar.css') }}" rel="stylesheet">
@endpush
<div>
... HTML contents
</div>
and I use the widget in an other blade like:
<div>
...
@include('widget')
</div>
<div>
...
@include('widget')
</div>
The problem is when I use the widget multiple times in a page the 'scripts' and 'styles' repeated multiple times.
How can I prevent Laravel to push 'scripts' and 'styles' multiple times?