Skip to content

Commit

Permalink
Fixed Blade resolution directive
Browse files Browse the repository at this point in the history
  • Loading branch information
asantibanez committed Jun 16, 2020
1 parent 5712dfa commit 7c739dc
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/LivewireSelectServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Asantibanez\LivewireSelect;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;

class LivewireSelectServiceProvider extends ServiceProvider
{
Expand All @@ -19,19 +19,10 @@ public function boot()
__DIR__.'/../resources/views' => resource_path('views/vendor/livewire-select'),
], 'livewire-select-views');
}
}

/**
* Register the application services.
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'livewire-select');

$this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
$bladeCompiler->directive('livewireSelectScripts', function () {
return <<<'HTML'
<script>
Blade::directive('livewireSelectScripts', function () {
return <<<'HTML'
<script>
window.livewire.on('livewire-select-focus-search', (data) => {
const el = document.getElementById(`${data.name || 'invalid'}`);
Expand All @@ -53,7 +44,14 @@ public function register()
});
</script>
HTML;
});
});
}

/**
* Register the application services.
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'livewire-select');
}
}

0 comments on commit 7c739dc

Please sign in to comment.