PHP code example of njoguamos / laravel-kenya-mobile
1. Go to this page and download the library: Download njoguamos/laravel-kenya-mobile library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
njoguamos / laravel-kenya-mobile example snippets
namespace App\Http\Requests;
use NjoguAmos\KeMobile\KenyaMobileFullRule;
use NjoguAmos\KeMobile\KenyaMobileRule;
use Illuminate\Foundation\Http\FormRequest;
class RegisterUserRequest extends FormRequest
{
/** @return array<string, mixed> */
public function rules(): array
{
return [
// ... other rules
// Validate phone number with 9 or 10 digits
'phone' => ['nullable', new KenyaMobileRule(),'unique:users,phone'],
// Or validate full phone number
'full_phone' => ['nullable', new KenyaMobileFullRule(),'unique:users,full_phone'],
];
}
}