Releases: spatie/laravel-data
4.15.2
- Fix: CannotCreateData exception when AutoWhenLoadedLazy relationship is not loaded (#1009)
- Fix: Inertia deferred properties not being that flexible
Full Changelog: 4.15.1...4.15.2
4.15.1
4.15.0
What's Changed
- Add test and doc changes by @rubenvanassche in #996
- Add support for inertia deferred props by @matthiasweiss in #939
- Add EmptyString support for Formik compatibility by @igorleszczynski in #955
- Update ide.json by @Yi-pixel in #990
- feature property morphable by @bentleyo in #995
Full Changelog: 4.14.1...4.15.0
4.14.1
What's Changed
Full Changelog: 4.14.0...4.14.1
4.14.0
If you're using cached versions of your data objects and don't clear this cache on deploy, now is the time since we've updated some internal structures.
Some internals structures (attributes) in the DataProperty
and DataClass
have changed, if you're using these classes, update them accordingly.
4.13.2
What's Changed
- Fix an issue where specific Lazy classes won't be recognized
Full Changelog: 4.13.1...4.13.2
4.13.1
Allow Laravel 12
What's Changed
- Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in #940
- Add "laravel-data-json-schemas" to third party packages by @BasilLangevin in #943
New Contributors
- @BasilLangevin made their first contribution in #943
Full Changelog: 4.13.0...4.13.1
4.13.0
4.12.0
What a release! Probably to biggest minor release we've ever done!
Some cool highlights:
Disabling optional values
Optional values are great, but sometimes a null
value is desirable from now on you can do the following:
class SongData extends Data {
public function __construct(
public string $title,
public string $artist,
public Optional|null|string $album,
) {
}
}
SongData::factory()
->withoutOptionalValues()
->from(['title' => 'Never gonna give you up', 'artist' => 'Rick Astley']); // album will `null` instead of `Optional`
Injecting property values
It was already possible to inject a Laravel route parameter when creating a data object, we've now extended this functionality quite a bit and also allow injecting dependencies from the container and the authenticated user.
class SongData extends Data {
#[FromAuthenticatedUser]
public UserData $user;
}
Merging manual rules
In the past when the validation rules of a property were manually defined, the automatic validation rules for that property were omitted. From now on, you can define manual validation rules and merge them with the automatically generated validation rules:
```php
#[MergeValidationRules]
class SongData extends Data
{
public function __construct(
public string $title,
public string $artist,
) {
}
public static function rules(): array
{
return [
'title' => ['max:20'],
'artist' => ['max:20'],
];
}
}
New property mappers:
We now ship by default a Uppercase
and Lowercase
mapper for mapping property names.
All changes:
- Fix GitHub action fail by @rust17 in #918
- Point to the right problem on ArgumentCountError exception by @nsvetozarevic in #884
- Fix an issue where anonymous classes in castables were serialized (#903) by @rubenvanassche in #923
- Add the ability to optionally merge automatically inferred rules with manual rules by @CWAscend in #848
- Implement enum json serialization by @dont-know-php in #896
- Use comments instead of docblocks in configuration file. by @edwinvdpol in #904
- Casting DateTimeInterface: Truncate nanoseconds to microseconds (first 6 digits) / with Tests by @yob-yob in #908
- Use container to call
Data::authorize()
to allow for dependencies by @cosmastech in #910 - Improve type for CreationContextFactory::alwaysValidate by @sanfair in #925
- Removed comma character from Data Rule stub by @andrey-helldar in #926
- Use BaseData contract i/o Data concrete in CollectionAnnotation by @riesjart in #928
- New mappers added:
LowerCaseMapper
andUpperCaseMapper
by @andrey-helldar in #927 - Allow disabling default Optional values in CreationContext by @ragulka in #931
- Fix introduction.md by @pikant in #937
- General code health improvements by @xHeaven in #920
- Filling properties from current user by @c-v-c-v in #879
Full Changelog: 4.11.1...4.12.0