1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Teofanis\SearchableDropdown; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\File; |
6
|
|
|
use Illuminate\Support\Facades\Blade; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
class SearchableDropdownServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Register services. |
13
|
|
|
* |
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function register() |
17
|
|
|
{ |
18
|
|
|
/** Register Components */ |
19
|
|
|
$this->loadViewsFrom(__DIR__.'/views/components', 'searchableDropdown'); |
20
|
|
|
Blade::component('searchableDropdown::dropdown', 'searchable-dropdown'); |
21
|
|
|
Blade::component('searchableDropdown::partials.list', 'searchable-dropdown-list'); |
22
|
|
|
Blade::component('searchableDropdown::partials.item', 'searchable-dropdown-list-item'); |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** Register Directives */ |
26
|
|
|
Blade::directive('searchableDropdownStyles', function(){ |
27
|
|
|
return '<link rel="stylesheet" href="{{asset(\'/css/searchable-dropdown-styles.css\')}}">'; |
28
|
|
|
}); |
29
|
|
|
|
30
|
|
|
Blade::directive('searchableDropdownScripts', function(){ |
31
|
|
|
return '<script src="{{asset(\'/js/searchable-dropdown-scripts.js\')}}"></script>'; |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
Blade::directive('bindJSInstance', function(){ |
35
|
|
|
return '<script> (function(){ var event = new CustomEvent(\'search-dropdown-ready\', { detail:"{{$dropdownFunctionName}}" }); window.dispatchEvent(event);})(); </script>'; |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'searchable-dropdown-config.php'); |
39
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/props.php', 'searchable-dropdown-props.php'); |
40
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Bootstrap services. |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
public function boot() |
49
|
|
|
{ |
50
|
|
|
//Load helpers |
51
|
|
|
if(File::exists(__DIR__.'/helpers.php')){ |
52
|
|
|
require __DIR__.'/helpers.php'; |
53
|
|
|
} |
54
|
|
|
/** Config Publishing */ |
55
|
|
|
$this->publishes([__DIR__.'/../config/config.php' => config_path('searchable-dropdown-config.php'), __DIR__.'/../config/props.php' => config_path('searchable-dropdown-props.php')], 'searchable-dropdown-config'); |
56
|
|
|
/** Asset Publishing */ |
57
|
|
|
$this->publishes([__DIR__.'/assets/js' => public_path('js'), __DIR__.'/assets/css' => public_path('css')],'searchable-dropdown-assets'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|