Skip to content

Commit 9968cb6

Browse files
Merge pull request #95 from serogaq/fix/JsonSerializable
Fixes missing JsonSerializable implementation
2 parents 07d95d7 + 025b184 commit 9968cb6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/SimpleDTO.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Http\UploadedFile;
1414
use Illuminate\Support\Collection;
1515
use Illuminate\Validation\ValidationException;
16+
use JsonSerializable;
1617
use ReflectionClass;
1718
use ReflectionProperty;
1819
use UnitEnum;
@@ -29,7 +30,7 @@
2930
use WendellAdriel\ValidatedDTO\Exceptions\CastTargetException;
3031
use WendellAdriel\ValidatedDTO\Exceptions\MissingCastTypeException;
3132

32-
abstract class SimpleDTO implements BaseDTO, CastsAttributes
33+
abstract class SimpleDTO implements BaseDTO, CastsAttributes, JsonSerializable
3334
{
3435
use DataResolver, DataTransformer;
3536

@@ -146,6 +147,14 @@ public function set($model, $key, $value, $attributes)
146147
return '';
147148
}
148149

150+
/*
151+
* JsonSerializable
152+
*/
153+
public function jsonSerialize(): mixed
154+
{
155+
return $this->toArray();
156+
}
157+
149158
/**
150159
* Maps the DTO properties before the DTO instantiation.
151160
*/

0 commit comments

Comments
 (0)