Files
laravel-backend/app/Providers/CorsServiceProvider.php
Joris Slagter df155bb13d
Some checks failed
continuous-integration/drone/push Build is failing
Initial Laravel API import
- Complete GGZ Ecademy Laravel backend application
- RESTful API for learning products, members, filters
- Authentication and authorization system
- Database migrations and seeders
- Custom CRUD generator commands
- Email notification system
- Integration with frontend applications
2025-12-02 17:40:21 +01:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Providers;
use App\Data\Validation\NetteValidator;
use App\Data\Validation\ValidatesArray;
use App\Services\CorsService;
use Illuminate\Support\ServiceProvider;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
class CorsServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->when(CorsService::class)
->needs(ValidatesArray::class)
->give(fn () => static::determineConfigValidator());
}
private static function determineConfigValidator(): ValidatesArray
{
return new NetteValidator(
new \Nette\Schema\Processor(),
static::getConfigValidationSchema(),
);
}
private static function getConfigValidationSchema(): Schema
{
return Expect::structure([
'path' => Expect::string(),
'origin' => Expect::string()->nullable(),
'methods' => Expect::arrayOf(Expect::string()),
'headers' => Expect::arrayOf(Expect::string()),
]);
}
}