1. Go to this page and download the library: Download nickescobedo/cambia 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/ */
nickescobedo / cambia example snippets
class Cast extends FormRequest
{
use CastRequestAttributes;
public function rules(): array
{
return [
'toBoolean' => 'string', // Fields not present in validation will not cast
];
}
public function casts(): array
{
return [
'toBoolean' => 'boolean',
];
}
}
enum Status: string
{
case Pending = 'pending';
}
public function casts(): array
{
return [
'status' => Status::class,
];
}
use Illuminate\Http\Request;
use NickEscobedo\Cambia\CastsRequestAttributes;
class JsonCast implements CastsRequestAttributes
{
public function get(Request $request, string $key, mixed $value, array $attributes)
{
return json_decode($value, true);
}
}
class Cast extends FormRequest
{
use CastRequestAttributes;
public function rules(): array
{
return [
'toBoolean' => 'string', // Fields not present in validation will not cast
];
}
public function casts(): array
{
return [
'toBoolean' => JsonCast::class,
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.