assurdeal / laravel-orias
在 Laravel 中使用 ORIAS 网络服务
v0.2.1
2024-07-12 07:45 UTC
Requires
- php: ^8.2
- ext-soap: *
- illuminate/support: ^11.0
- ricorocks-digital-agency/soap: ^2.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^2.20
- pestphp/pest-plugin-laravel: ^2.0
README
此包允许您将 ORIAS 网络服务集成到您的 Laravel 应用程序中。您可以使用它来验证 ORIAS 号码或检索有关经纪人的信息。
安装
您可以通过 composer 安装此包
composer require assurdeal/laravel-orias
将您的 ORIAS 网络服务 API 密钥添加到 .env
文件中
ORIAS_KEY=your-api-key
使用
use Assurdeal\LaravelOrias\Requests\ShowBrokerRequest; $response = ShowBrokerRequest::make('123456789')->send(); /** @var \Assurdeal\LaravelOrias\Data\Intermediary $dto */ $dto = $response->dto();
作为验证器的使用
use Assurdeal\LaravelOrias\Rules\RegisteredIntermediary; use Assurdeal\LaravelOrias\Enums\RegistrationCategory; Validator::make($data, [ 'orias' => ['required', new RegisteredIntermediary()], ]); Validator::make($data, [ 'orias' => [ 'required', (new RegisteredIntermediary())->withAllOfCategories( RegistrationCategory::COA, RegistrationCategory::AGA ) ], ]); Validator::make($data, [ 'orias' => [ 'required', (new RegisteredIntermediary())->withAnyOfCategories( RegistrationCategory::COA, RegistrationCategory::AGA ) ], ]);
翻译
将以下行添加到您的 lang/xx.json
文件中,其中 xx
表示您要翻译的locale。
例如 resources/fr.json
{ "The :attribute is not of a valid length.": "Le :attribute n'est pas d'une longueur valide.", "The :attribute is not a registered intermediary.": "Le :attribute n'est pas un intermédiaire enregistré.", "The :attribute was not found in the registry of intermediaries.": "Le :attribute n'a pas été trouvé dans le registre des intermédiaires.", "The :attribute is not registered for any of the valid categories.": "Le :attribute n'est pas enregistré pour aucune des catégories valides.", "The :attribute is not registered for all of the valid categories.": "Le :attribute n'est pas enregistré pour toutes les catégories valides." }
测试
composer test
致谢
许可
MIT 许可证(MIT)。请参阅 许可文件 以获取更多信息。