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.
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
Full Changelog: https://github.com/spatie/laravel-data/compare/4.5.0...4.5.1
DataCollectable transformation by @innocenzi in https://github.com/spatie/laravel-data/pull/696date_format rule by @riesjart in https://github.com/spatie/laravel-data/pull/727list validation rule by @riesjart in https://github.com/spatie/laravel-data/pull/728Full Changelog: https://github.com/spatie/laravel-data/compare/4.4.1...4.5.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.4.0...4.4.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.3.2...4.4.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.3.1...4.3.2
null for fieldContext within resolvePotentialPartialArray by @faustbrian in https://github.com/spatie/laravel-data/pull/693Full Changelog: https://github.com/spatie/laravel-data/compare/4.3.0...4.3.1
Full Changelog: https://github.com/spatie/laravel-data/compare/4.2.0...4.3.0
Full Changelog: https://github.com/spatie/laravel-data/compare/4.1.0...4.2.0
Full Changelog: https://github.com/spatie/laravel-data/compare/3.11.0...3.11.1
getRule to fix issues with caching and typescript transformernull or an empty arraynull to collect and return an empty version of the defined output typeLaravel-data 4.0.0 was released 5 hours ago, time for an update!
PropertyRulesA fresh release after a month of vacation, enjoy!
CustomValidationAttribute'smake:data command (#449, #335)StudlyMapperVersion 2 of laravel-data is a complete overhaul, we've almost completely rewritten the package.
This is a (non-complete) list of the new features:
only and except methods on Data and DataCollectionslinks array to the paginated responselazy::whenLoaded closure when the relation is nullWithoutValidation attributeisBuiltIn from DataPropertyEnumauthorized method to authorizeRequest object is given not only when a data object is injectedDataFromRequestResolverDataValidatorResolverspatie/test-time dependency to require-devWithData trait for quicker getting data from objectsFull Changelog: https://github.com/spatie/laravel-data/compare/1.3.2...1.3.3
from without parametersSome more "internal" changes
How can I help you explore Laravel packages today?