mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-09-28 18:13:06 -04:00
178 lines
5.8 KiB
PHP
178 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\JobPortal\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Database\Eloquent\Factory;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class JobPortalServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* @var string $moduleName
|
|
*/
|
|
protected $moduleName = 'JobPortal';
|
|
|
|
/**
|
|
* @var string $moduleNameLower
|
|
*/
|
|
protected $moduleNameLower = 'jobportal';
|
|
|
|
/**
|
|
* Boot the application events.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerTranslations();
|
|
$this->registerConfig();
|
|
$this->registerViews();
|
|
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
|
|
|
if(Schema::hasTable('jp_settings')){
|
|
|
|
// Load Email Config from Database
|
|
if(!empty(setting_item('email_driver'))){
|
|
Config::set('mail.driver',setting_item("email_driver"));
|
|
switch (setting_item("email_driver")){
|
|
case 'mailgun':
|
|
if(!empty(setting_item('email_mailgun_domain'))){
|
|
Config::set('services.mailgun.domain',setting_item("email_mailgun_domain"));
|
|
}
|
|
if(!empty(setting_item('email_mailgun_secret'))){
|
|
Config::set('services.mailgun.secret',setting_item("email_mailgun_secret"));
|
|
}
|
|
if(!empty(setting_item('email_mailgun_endpoint'))){
|
|
Config::set('services.mailgun.endpoint',setting_item("email_mailgun_endpoint"));
|
|
}
|
|
break;
|
|
case 'postmark':
|
|
if(!empty(setting_item('email_postmark_token'))){
|
|
Config::set('services.postmark.token',setting_item("email_postmark_token"));
|
|
}
|
|
break;
|
|
case 'ses':
|
|
if(!empty(setting_item('email_ses_key'))){
|
|
Config::set('services.ses.key',setting_item("email_ses_key"));
|
|
}
|
|
if(!empty(setting_item('email_ses_secret'))){
|
|
Config::set('services.ses.secret',setting_item("email_ses_secret"));
|
|
}
|
|
if(!empty(setting_item('email_ses_region'))){
|
|
Config::set('services.ses.region',setting_item("email_ses_region"));
|
|
}
|
|
break;
|
|
case 'sparkpost':
|
|
if(!empty(setting_item('email_sparkpost_secret'))){
|
|
Config::set('services.sparkpost.secret',setting_item("email_sparkpost_secret"));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if(!empty(setting_item('email_host'))){
|
|
Config::set('mail.host',setting_item("email_host"));
|
|
}
|
|
if(!empty(setting_item('email_port'))){
|
|
Config::set('mail.port',setting_item("email_port"));
|
|
}
|
|
if(!empty(setting_item('email_encryption'))){
|
|
Config::set('mail.encryption',setting_item("email_encryption"));
|
|
}
|
|
if(!empty(setting_item('email_username'))){
|
|
Config::set('mail.username',setting_item("email_username"));
|
|
}
|
|
if(!empty(setting_item('email_password'))){
|
|
Config::set('mail.password',setting_item("email_password"));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the service provider.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->app->register(RouteServiceProvider::class);
|
|
|
|
//add new filesystem config
|
|
Config::set('filesystems.disks.uploads', [
|
|
'driver' => 'local',
|
|
'root' => public_path('uploads')
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Register config.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function registerConfig()
|
|
{
|
|
$this->publishes([
|
|
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
|
], 'config');
|
|
$this->mergeConfigFrom(
|
|
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Register views.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function registerViews()
|
|
{
|
|
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
|
|
|
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
|
|
|
$this->publishes([
|
|
$sourcePath => $viewPath
|
|
], ['views', $this->moduleNameLower . '-module-views']);
|
|
|
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
|
}
|
|
|
|
/**
|
|
* Register translations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function registerTranslations()
|
|
{
|
|
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
|
|
|
if (is_dir($langPath)) {
|
|
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
|
} else {
|
|
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the services provided by the provider.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function provides()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
private function getPublishableViewPaths(): array
|
|
{
|
|
$paths = [];
|
|
foreach (\Config::get('view.paths') as $path) {
|
|
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
|
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
|
}
|
|
}
|
|
return $paths;
|
|
}
|
|
}
|