<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jessarcher / laravel-castable-data-transfer-object example snippets
namespace App\Models;
use App\Values\Address;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $casts = [
'address' => Address::class,
];
}
namespace App\Models;
use App\Values\Address;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $casts = [
'settings' => Settings::class . ':nullable',
];
}
use JessArcher\CastableDataTransferObject\CastableDataTransferObject;
class Settings extends CastableDataTransferObject
{
public string $title = 'Default';
}
use JessArcher\CastableDataTransferObject\CastableDataTransferObject;
use JessArcher\CastableDataTransferObject\CastUsingJsonFlags;
#[CastUsingJsonFlags(encode: JSON_PRESERVE_ZERO_FRACTION)]
class Address extends CastableDataTransferObject {}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.