90 lines
2.5 KiB
PHP
90 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Admin\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Livewire\Livewire;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class ModuleServiceProvider extends ServiceProvider
|
|
{
|
|
protected string $moduleName = 'Admin';
|
|
|
|
protected $policies = [
|
|
\Modules\User\Models\User::class => \Modules\Admin\Http\Policies\AdminPathPolicy::class
|
|
];
|
|
public function register()
|
|
{
|
|
$this->app->register(AuthServiceProvider::class);
|
|
$this->app->register(RouteServiceProvider::class);
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
$this->registerViews();
|
|
$this->registerLivewireViews();
|
|
$this->registerMigrations();
|
|
$this->registerConfig();
|
|
$this->registerComponent();
|
|
$this->registerLivewire();
|
|
//$this->registerPolicies();
|
|
}
|
|
|
|
protected function registerViews()
|
|
{
|
|
$moduleViewsPath = __DIR__ . '/../Views';
|
|
$this->loadViewsFrom(
|
|
$moduleViewsPath,
|
|
strtolower($this->moduleName)
|
|
);
|
|
}
|
|
|
|
protected function registerLivewireViews()
|
|
{
|
|
$moduleViewsPath = __DIR__ . '/../Views/livewire';
|
|
$this->loadViewsFrom(
|
|
$moduleViewsPath,
|
|
strtolower($this->moduleName)
|
|
);
|
|
}
|
|
|
|
protected function registerMigrations()
|
|
{
|
|
$this->loadMigrationsFrom(
|
|
app_path('Modules/' . $this->moduleName . '/Database/Migrations')
|
|
);
|
|
}
|
|
|
|
protected function registerConfig()
|
|
{
|
|
$path = app_path('Modules/' . $this->moduleName . '/Config/config.php');
|
|
$this->mergeConfigFrom(
|
|
$path,
|
|
strtolower($this->moduleName)
|
|
);
|
|
}
|
|
|
|
protected function registerLivewire()
|
|
{
|
|
Livewire::component('admin.menu', \Modules\Admin\Http\Livewire\AdminMenu::class);
|
|
Livewire::component('admin.posts', \Modules\Admin\Http\Livewire\Posts::class);
|
|
Livewire::component('admin.payments', \Modules\Admin\Http\Livewire\Payments::class);
|
|
|
|
}
|
|
|
|
protected function registerComponent()
|
|
{
|
|
//Blade::component('<name>', \Modules\<NAME>\Http\Components\<NAME>::class);
|
|
}
|
|
|
|
protected function registerPolicies1()
|
|
{
|
|
|
|
Gate::policy(\Modules\User\Models\User::class, \Modules\Admin\Http\Policies\AdminPathPolicy::class);
|
|
/*Gate::define('viewAdminPath', function ($user)
|
|
{
|
|
return Gate::authorize('viewAdminPath', \Modules\Admin\Http\Policies\AdminPathPolicy::class);
|
|
});*/
|
|
}
|
|
} |