%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/vendor/mitchbred/entrust/src/Entrust/ |
Upload File : |
<?php namespace Trebol\Entrust;
/**
* This file is part of Entrust,
* a role & permission management solution for Laravel.
*
* @license MIT
* @package Trebol\Entrust
*/
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class EntrustServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
// Publish config files
$this->publishes([
__DIR__.'/../config/config.php' => app()->basePath() . '/config/entrust.php',
]);
// Register commands
$this->commands('command.entrust.migration');
// Register blade directives
$this->bladeDirectives();
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerEntrust();
$this->registerCommands();
$this->mergeConfig();
}
/**
* Register the blade directives
*
* @return void
*/
private function bladeDirectives()
{
if (!class_exists('\Blade')) return;
// Call to Entrust::hasRole
Blade::directive('role', function($expression) {
return "<?php if (\\Entrust::hasRole({$expression})) : ?>";
});
Blade::directive('endrole', function($expression) {
return "<?php endif; // Entrust::hasRole ?>";
});
// Call to Entrust::can
Blade::directive('permission', function($expression) {
return "<?php if (\\Entrust::can({$expression})) : ?>";
});
Blade::directive('endpermission', function($expression) {
return "<?php endif; // Entrust::can ?>";
});
// Call to Entrust::ability
Blade::directive('ability', function($expression) {
return "<?php if (\\Entrust::ability({$expression})) : ?>";
});
Blade::directive('endability', function($expression) {
return "<?php endif; // Entrust::ability ?>";
});
}
/**
* Register the application bindings.
*
* @return void
*/
private function registerEntrust()
{
$this->app->bind('entrust', function ($app) {
return new Entrust($app);
});
$this->app->alias('entrust', 'Trebol\Entrust\Entrust');
}
/**
* Register the artisan commands.
*
* @return void
*/
private function registerCommands()
{
$this->app->singleton('command.entrust.migration', function ($app) {
return new MigrationCommand();
});
}
/**
* Merges user's and entrust's configs.
*
* @return void
*/
private function mergeConfig()
{
$this->mergeConfigFrom(
__DIR__.'/../config/config.php', 'entrust'
);
}
/**
* Get the services provided.
*
* @return array
*/
public function provides()
{
return [
'command.entrust.migration'
];
}
}