-
Notifications
You must be signed in to change notification settings - Fork 1
/
IfaToursServiceProvider.php
156 lines (130 loc) · 3.77 KB
/
IfaToursServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
namespace Modules\IfaTours\Providers;
use App\Models\Airport;
use App\Models\Flight;
use App\Services\ModuleService;
use Illuminate\Support\ServiceProvider;
use Route;
class IfaToursServiceProvider extends ServiceProvider
{
protected $moduleSvc;
/**
* Boot the application events.
*/
public function boot()
{
$this->moduleSvc = app(ModuleService::class);
$this->registerRoutes();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->registerLinks();
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
$this->publishes([
__DIR__.'/../Resources/assets/tinymce' => public_path('vendor/ifatours/tinymce'),
], 'public');
Flight::macro('dpt_airport', function() {
return $this->belongsTo(Airport::class, 'dpt_airport_id');
});
Flight::macro('arr_airport', function() {
return $this->belongsTo(Airport::class, 'arr_airport_id');
});
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'ifatours');
$this->publishes([
__DIR__.'/../Resources/views' => resource_path('views/vendor/ifatours'),
], 'views');
}
/**
* Register the service provider.
*/
public function register()
{
//
}
/**
* Add module links here
*/
public function registerLinks()
{
$this->moduleSvc->addAdminLink('IFA Tours', '/admin/ifatours');
$this->moduleSvc->addFrontendLink('Tours & Charters', '/ifatours/tours', '', false);
}
/**
* Register the routes
*/
protected function registerRoutes()
{
/*
* Routes for the frontend
*/
Route::group([
'as' => 'ifatours.',
'prefix' => 'ifatours',
'middleware' => ['web'],
'namespace' => 'Modules\IfaTours\Http\Controllers',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
});
/*
* Routes for the admin
*/
Route::group([
'as' => 'ifatours.',
'prefix' => 'admin/ifatours',
'middleware' => ['web', 'role:admin'],
'namespace' => 'Modules\IfaTours\Http\Controllers\Admin',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/admin.php');
});
}
/**
* Register config.
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('ifatours.php'),
], 'config');
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', 'ifatours'
);
}
/**
* Register views.
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/IfaTours');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath,
], 'views');
$paths = array_map(
function ($path) {
return $path.'/modules/IfaTours';
},
\Config::get('view.paths')
);
$paths[] = $sourcePath;
$this->loadViewsFrom($paths, 'ifatours');
}
/**
* Register translations.
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/IfaTours');
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'ifatours');
} else {
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'ifatours');
}
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
}