@nuclearcoconut Put it to the register method instead of boot
public function register()
{
$this->app->singleton(InitializeRoles::class, function () {
return new InitializeRoles();
});
}
Singleton is called just once for every request.It's a normal behaviour.
If you don't want to execute that code you can use cache for it with singleton.
use Illuminate\Support\Facades\Cache;
public function register()
{
$this->app->singleton(InitializeRoles::class, function () {
return Cache::remember('roles', now()->addDay(), function () {
return new InitializeRoles();
});
});
}