1. Go to this page and download the library: Download actengage/sanitize 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/ */
use Actengage\Sanitize\Casts\Email;
use Actengage\Sanitize\Casts\Phone;
use Actengage\Sanitize\Casts\Zip;
class User extends Model {
protected $guarded = [];
protected $casts = [
'email' => Email::class,
'phone' => Phone::class,
'zip' => Zip::class,
];
}
$user = User::create([
'email' => '[email protected]',
'phone' => '1-800-555-1234',
'zip' => '1234',
])
dd($user->email); // [email protected]
dd($user->phone); // 8005001234
dd($user->zip); // 01234
use Actengage\Sanitize\Sanitizers\Email;
use Actengage\Sanitize\Sanitizers\Phone;
use Actengage\Sanitize\Sanitizers\Zip;
return [
/*
|--------------------------------------------------------------------------
| Sanitizers
|--------------------------------------------------------------------------
|
| This value is an array of invokable classes that implement the Sanitizer
| interface. These are the default macros associated with the Sanitizer
| instance.
|
| use Actengage\Sanitize\Facades\Sanitize;
|
| Sanitize::email('test @test.com'); // [email protected]
| Sanitize::phone('(888) 555-1234'); // 8885551234
| Sanitize::zip('12345-1234'); // 123451234
|
*/
'sanitizers' => [
'email' => Email::class,
'phone' => Phone::class,
'zip' => Zip::class,
]
];