53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Auth\TenantAwareUserProvider;
|
|
use App\Models\License;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Policies\LicensePolicy;
|
|
use App\Policies\TenantPolicy;
|
|
use App\Policies\UserPolicy;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if (app()->environment() !== 'testing') {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
Auth::provider('tenant-aware-eloquent', function ($app, array $config) {
|
|
return new TenantAwareUserProvider($app['hash'], $config['model']);
|
|
});
|
|
|
|
Gate::policy(User::class, UserPolicy::class);
|
|
Gate::policy(License::class, LicensePolicy::class);
|
|
Gate::policy(Tenant::class, TenantPolicy::class);
|
|
|
|
Gate::define('attach-parent-child', function ($user, $parent, $child) {
|
|
return (new \App\Policies\ParentChildPolicy)->attach($user, $parent, $child);
|
|
});
|
|
|
|
Gate::define('detach-parent-child', function ($user, $parent, $child) {
|
|
return (new \App\Policies\ParentChildPolicy)->detach($user, $parent, $child);
|
|
});
|
|
}
|
|
}
|