|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the Laravel Navigation Toastr package. |
|
6
|
|
|
* |
|
7
|
|
|
* (c) Mujtech Mujeeb <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Mujhtech\NavToastr; |
|
14
|
|
|
|
|
15
|
|
|
use Illuminate\Support\ServiceProvider; |
|
16
|
|
|
use Illuminate\Support\Facades\Blade; |
|
17
|
|
|
use Illuminate\Container\Container; |
|
18
|
|
|
use Mujhtech\NavToastr\Console\NavToastrInstallCommand; |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
include_once(__DIR__.'/Helpers.php'); |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
class NavToastrServiceProvider extends ServiceProvider |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Register services. |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
public function register() |
|
33
|
|
|
{ |
|
34
|
|
|
// |
|
35
|
|
|
$this->app->bind('nav-toastr', function (Container $app) { |
|
36
|
|
|
|
|
37
|
|
|
return new NavToastr($app['session'], $app['config']); |
|
38
|
|
|
|
|
39
|
|
|
}); |
|
40
|
|
|
|
|
41
|
|
|
$this->registerBladeDirectives(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Bootstrap the application events. |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function boot() |
|
53
|
|
|
{ |
|
54
|
|
|
|
|
55
|
|
|
$this->registerCommands(); |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get the services provided by the provider |
|
62
|
|
|
* @return array |
|
63
|
|
|
*/ |
|
64
|
|
|
|
|
65
|
|
|
public function provides() |
|
66
|
|
|
{ |
|
67
|
|
|
return ['nav-toastr']; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
private function registerCommands() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->commands([ |
|
74
|
|
|
NavToastrInstallCommand::class, |
|
75
|
|
|
]); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
public function registerBladeDirectives() |
|
80
|
|
|
{ |
|
81
|
|
|
Blade::directive('navtoastrRender', function () { |
|
82
|
|
|
return "<?php echo app('nav-toastr')->show(); ?>"; |
|
83
|
|
|
}); |
|
84
|
|
|
|
|
85
|
|
|
Blade::directive('navtoastrCss', function () { |
|
86
|
|
|
return "<?php echo toastr_css(); ?>"; |
|
87
|
|
|
}); |
|
88
|
|
|
|
|
89
|
|
|
Blade::directive('navtoastrJs', function () { |
|
90
|
|
|
return "<?php echo toastr_js(); ?>"; |
|
91
|
|
|
}); |
|
92
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |