28 lines
793 B
PHP
28 lines
793 B
PHP
<?php
|
|
|
|
namespace Modules\ActiveDirectory\Providers;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Modules\ActiveDirectory\Console\Commands\SyncActiveDirectory;
|
|
|
|
class ActiveDirectoryServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'ad-sync');
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
|
|
Gate::define('manage-directory-sync', fn (User $user): bool => $user->ad_guid === null
|
|
&& $user->id === config('ad-sync.admin-id'));
|
|
|
|
if ($this->app->runningInConsole()) {
|
|
$this->commands([SyncActiveDirectory::class]);
|
|
}
|
|
}
|
|
}
|