spatie/laravel-data
Define rich, typed data objects once and use them for requests, validation, API resources/transformers, and TypeScript definitions. Create from arrays/requests/models, apply rules automatically, and transform only what’s needed with lazy properties.
Full Changelog: https://github.com/spatie/laravel-data/compare/4.20.1...4.21.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.19.0...4.19.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.18.0...4.19.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.17.1...4.18.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.17.0...4.17.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.16.1...4.17.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.16.0...4.16.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.15.3...4.16.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.15.2...4.15.3
Full Changelog: https://github.com/spatie/laravel-data/compare/4.15.1...4.15.2
Full Changelog: https://github.com/spatie/laravel-data/compare/4.15.0...4.15.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.14.1...4.15.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.14.0...4.14.1
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.
Full Changelog: https://github.com/spatie/laravel-data/compare/4.13.1...4.13.2
Allow Laravel 12
Full Changelog: https://github.com/spatie/laravel-data/compare/4.13.0...4.13.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.12.0...4.13.0
What a release! Probably to biggest minor release we've ever done!
Some cool highlights:
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`
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;
}
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'],
];
}
}
We now ship by default a Uppercase and Lowercase mapper for mapping property names.
Data::authorize() to allow for dependencies by @cosmastech in https://github.com/spatie/laravel-data/pull/910LowerCaseMapper and UpperCaseMapper by @andrey-helldar in https://github.com/spatie/laravel-data/pull/927Full Changelog: https://github.com/spatie/laravel-data/compare/4.11.1...4.12.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.10.1...4.11.0
It has been a fews weeks, a mostly bugfix release with one new feature, enjoy!
Full Changelog: https://github.com/spatie/laravel-data/compare/4.7.2...4.8.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.7.0...4.7.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.6.0...4.7.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.5.1...4.6.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.5.1...3.12.0
How can I help you explore Laravel packages today?