Download the PHP package cherif/algerian-mobile-phone-number-laravel without Composer
On this page you can find all versions of the php package cherif/algerian-mobile-phone-number-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cherif/algerian-mobile-phone-number-laravel
More information about cherif/algerian-mobile-phone-number-laravel
Files in cherif/algerian-mobile-phone-number-laravel
Package algerian-mobile-phone-number-laravel
Short Description Allows to use cherif/algerian-mobile-number in Laravel
License MIT
Informations about the package algerian-mobile-phone-number-laravel
cherif/algerian-mobile-phone-number-laravel
Allows to use cherif/algerian-mobile-phone-number value object with Laravel.
Installtion
The recommended way of installation is by using Packagist and Composer.
The following command should be executed in order to add the package as a requirement to composer.json
of a project:
Usage:
The package have 2 main classes to use Cherif\AlgerianMobilePhoneNumber\Laravel\Casts\AlgerianMobilePhoneNumberCast
and Cherif\AlgerianMobilePhoneNumber\Laravel\Rules\AlgerianMobilePhoneNumberRule
to cast models attributes from/to the phone number value object and validate the request respectively:
Eloquent model attribute casting:
To use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber
value object instance as Eloquent model attribute use the casting class in the casts
model's property like the following:
The definition above allows to use the mobile_phone_number
as value object when reading the attribute, the casting to string value will be handled during setting the value and persisting the model in the database.
Validation:
The mobile phone validator is Cherif\AlgerianMobilePhoneNumber\Laravel\Rules\AlgerianMobilePhoneNumberRule
it can be used with the request to validate the input:
Contribution
Contributions are welcome to make this library better.
- Clone the repo:
and enter to the cloned repository directory.
- Install dependencies:
Testing:
License
MIT License.