39 lines
905 B
PHP
39 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The model to policy mappings for the application.
|
|
*
|
|
* @var array<class-string, class-string>
|
|
*/
|
|
protected $policies = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
// Define gates for roles
|
|
Gate::define('admin', function ($user) {
|
|
return $user->role === 'admin';
|
|
});
|
|
|
|
Gate::define('penjahit', function ($user) {
|
|
return $user->role === 'penjahit';
|
|
});
|
|
|
|
Gate::define('pelanggan', function ($user) {
|
|
return $user->role === 'pelanggan';
|
|
});
|
|
}
|
|
}
|