2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2019-01-16 10:28:06 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
use App\Policies\ClientPolicy;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Auth;
|
2019-01-16 10:28:06 +01:00
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The policy mappings for the application.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $policies = [
|
2019-01-16 10:28:06 +01:00
|
|
|
Client::class => ClientPolicy::class,
|
2018-10-04 19:10:43 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any authentication / authorization services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-11-03 02:01:40 +01:00
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
$this->registerPolicies();
|
|
|
|
|
2018-10-15 11:06:57 +02:00
|
|
|
Auth::provider('users', function ($app, array $config) {
|
|
|
|
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
|
|
|
|
});
|
|
|
|
|
2018-11-03 02:01:40 +01:00
|
|
|
Auth::provider('contacts', function ($app, array $config) {
|
|
|
|
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
|
|
|
|
|
|
|
|
});
|
2019-01-20 06:00:50 +01:00
|
|
|
|
|
|
|
Gate::define('view-list', function ($user, $entity) {
|
|
|
|
|
|
|
|
$entity = strtolower(class_basename($entity));
|
|
|
|
|
|
|
|
return $user->hasPermission('view_' . $entity) || $user->isAdmin();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-11-03 02:01:40 +01:00
|
|
|
}
|
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|