8
8
use Illuminate \Database \Eloquent \Collection ;
9
9
use Illuminate \Support \Facades \App ;
10
10
use Illuminate \Support \Facades \Blade ;
11
- /* Macros */
11
+ // Macros
12
12
use Illuminate \Support \Facades \Response ;
13
13
use Illuminate \Support \Facades \Router ;
14
14
use Illuminate \Support \ServiceProvider ;
@@ -38,6 +38,17 @@ public function register(): void
38
38
*/
39
39
public function boot ()
40
40
{
41
+ if (!($ this ->app ->configurationIsCached ())) {
42
+ $ config = require __DIR__ . '/config.defaults.php ' ;
43
+ $ this ->app ['config ' ]->set ('vuex-hydrate ' , array_merge_phase (
44
+ $ config ,
45
+ $ this ->app ['config ' ]->get ('vuex-hydrate ' , [])
46
+ ));
47
+ }
48
+
49
+ // php artisan vendor:publish --provider="Phased\Routing\PhaseServiceProvider" --tag="config"
50
+ $ this ->publishes ([__DIR__ . '/config.defaults.php ' => config_path ('vuex-hydrate.php ' )], 'config ' );
51
+
41
52
$ this ->autoDiscoverModuleLoaders ();
42
53
43
54
$ this ->registerCommands ();
@@ -52,9 +63,9 @@ public function boot()
52
63
protected function autoDiscoverModuleLoaders ()
53
64
{
54
65
// TODO: Register folders as namespaced modules
55
- $ automatic = collect (glob (app_path (). '/VuexLoaders/*ModuleLoader.php ' ))
66
+ $ automatic = collect (glob (app_path () . '/VuexLoaders/*ModuleLoader.php ' ))
56
67
->map (function ($ file ) {
57
- $ dropPath = Str::replaceFirst (app_path (). '/ ' , Container::getInstance ()->getNamespace (), $ file );
68
+ $ dropPath = Str::replaceFirst (app_path () . '/ ' , Container::getInstance ()->getNamespace (), $ file );
58
69
$ dropExtension = Str::replaceLast ('.php ' , '' , $ dropPath );
59
70
60
71
return str_replace ('/ ' , '\\' , $ dropExtension );
@@ -93,9 +104,9 @@ public function setDirectives()
93
104
{
94
105
Blade::directive ('vuex ' , function () {
95
106
return "<?='<script id=\' "
96
- .config ('phase .initial_state_id ' , 'phase-state ' ). "\'>window. "
97
- .config ('phase .initial_state_key ' , '__PHASE_STATE__ ' )
98
- ."='.Pderas\VuexHydrate\Facades\Vuex::toJson().'</script>';?> " ;
107
+ . config ('vuex-hydrate .initial_state_id ' , 'phase-state ' ) . "\'>window. "
108
+ . config ('vuex-hydrate .initial_state_key ' , '__PHASE_STATE__ ' )
109
+ . "='.Pderas\VuexHydrate\Facades\Vuex::toJson().'</script>';?> " ;
99
110
});
100
111
}
101
112
}
0 commit comments