This package can be used with Laravel 8.0 or higher.
Install the package via composer:
composer require siriondev/consellrepThe 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,
];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"You may also want to publish the migration to add the idrepublicana field into your users table:
php artisan vendor:publish --tag="consellrep-migrations"php artisan optimizeYou 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'
];
}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
}
}
}