Creating DTOs
Creating data transfer object classes and adding properties to them in a proper way so they can be mapped.
Mapped data types
Models binding
use OpenSoutheners\LaravelDto\DataTransferObject;
use App\Models\Tag;
final class CreatePostData extends DataTransferObject
{
public function __construct(
public string $title,
public string $content,
public Tag $tag,
) {
//
}
}Customise binding attribute
Binding with relationships loaded
Morph binding
Customise binding attribute
Binding with relationships loaded
Mapping collections
Mapping with default values
Default value using attribute
Default value as authenticated user
Last updated