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-567-1234',
'zip' => '1234',
]);
$user->email; // [email protected]
$user->phone; // 8005671234
$user->zip; // 01234
use Actengage\Sanitize\Rules\Email;
use Actengage\Sanitize\Rules\Phone;
use Actengage\Sanitize\Rules\Zip;
$request->validate([
'email' => ['
use Actengage\Sanitize\Http\Middleware\SanitizeInputs;
Route::middleware(SanitizeInputs::class)->group(function () {
// Request inputs for email, phone, and zip are sanitized automatically
});
use Actengage\Sanitize\Facades\Sanitize;
Sanitize::macro('number', function (?string $value) {
return is_numeric($value) ? $value : null;
});
Sanitize::number('123'); // "123"
Sanitize::number('abc'); // null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.