You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ class Address extends CastableDataTransferObject
44
44
45
45
### 2. Configure your Eloquent attribute to cast to it:
46
46
47
-
Note that this should be `jsonb` or `json` column in your database schema.
47
+
Note that this should be a `jsonb` or `json` column in your database schema.
48
48
49
49
```php
50
50
namespace App\Models;
@@ -60,9 +60,34 @@ class User extends Model
60
60
}
61
61
```
62
62
63
-
And that's it! You can pass either an instance of your `Address` class, or even just an array with a compatible structure. It will automatically be cast to and from your class and JSON for storage.
63
+
And that's it! You can now pass either an instance of your `Address` class, or even just an array with a compatible structure. It will automatically be cast between your class and JSON for storage and the data will be validated on the way in and out.
64
64
65
-
Your data will be validated on the way in and out. But the best part is that you can decorate your class with domain-specific methods to turn it into a powerful value object.
0 commit comments