siriondev/consellrep
Composer 安装命令:
composer require siriondev/consellrep
包简介
Composer package per a la integració amb el procés de validació de la Identitat Digital Republicana del Consell per la República Catalana
README 文档
README
Installation
This package can be used with Laravel 8.0 or higher.
Install the package via composer:
composer require siriondev/consellrep
The service provider will automatically get registered. You may manually add the service provider in your config/app.php file:
'providers' => [ // ... Siriondev\ConsellRepublica\Providers\ConsellRepublicaProvider::class, ];
Config and Translations
You should publish the translations and the config/cxr.php config file with:
php artisan vendor:publish --tag="consellrep-config" php artisan vendor:publish --tag="consellrep-translations"
Migrations
You may also want to publish the migration to add the idrepublicana field into your users table:
php artisan vendor:publish --tag="consellrep-migrations"
Clear your config cache
php artisan optimize
Usage
Validator
You can use the idrepublicana rule to check whether the user input is valid or not.
public function rules() { return [ 'id' => 'required|idrepublicana' ]; }
You can also set parameters to check whether the IDR is valid, active, underaged, or just check the format.
public function rules() { return [ 'id' => 'required|idrepublicana:active,valid,underaged,format' ]; }
Facade
You can also use the IdentitatDigitalRepublicana Facade.
The validate method returns an object that can be used to check different attributes from the IDR.
use Siriondev\ConsellRepublica\Facades\IdentitatDigitalRepublicana; class Controller extends BaseController { public function register(Request $request) { $idr = IdentitatDigitalRepublicana::validate($request->id); if ($idr->getStatus()) { // Request OK $idr->isValid(); // IDR is valid $idr->isActive(); // IDR is active $idr->isUnderaged(); // IDR is underaged $idr->isFormat(); // IDR format correct (C-999-99999) } else { $idr->getMessage(); // Get the error message } } }
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2021-04-11