diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c6b5b6..e1d182ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes to `laravel-data` will be documented in this file. +## 4.6.0 - 2024-05-03 + +### What's Changed + +- Add initial support for casting union types +- Fix an issue with paginator includes not working +- Fix consistency of After, AfterOrEqual, Before, BeforeOrEquals rules +- Fix creation context issue (#749) +- Fix an performance issue where when creating a data object from models, the attributes were always called +- Add a #[LoadRelation] attribute which allows loading model relations when creating data objects on the fly + +**Full Changelog**: https://github.com/spatie/laravel-data/compare/4.5.1...4.6.0 + ## 3.12.0 - 2024-04-24 ### What's Changed diff --git a/docs/advanced-usage/creating-a-cast.md b/docs/advanced-usage/creating-a-cast.md index 3a7b3384..cf8da9fb 100644 --- a/docs/advanced-usage/creating-a-cast.md +++ b/docs/advanced-usage/creating-a-cast.md @@ -71,6 +71,7 @@ namespace Spatie\LaravelData\Tests\Fakes\Castables; use Spatie\LaravelData\Casts\Cast; use Spatie\LaravelData\Casts\Castable; +use Spatie\LaravelData\Support\Creation\CreationContext; use Spatie\LaravelData\Support\DataProperty; class Email implements Castable @@ -82,7 +83,7 @@ class Email implements Castable public static function dataCastUsing(...$arguments): Cast { return new class implements Cast { - public function cast(DataProperty $property, mixed $value, array $context): mixed { + public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed return new Email($value); } }; diff --git a/docs/advanced-usage/use-with-livewire.md b/docs/advanced-usage/use-with-livewire.md index 0c43696a..43279d42 100644 --- a/docs/advanced-usage/use-with-livewire.md +++ b/docs/advanced-usage/use-with-livewire.md @@ -104,10 +104,12 @@ requests the includes should be permanent. It is possible to query lazy nested data objects, it is however not possible to query lazy properties which are not a data: ```php -use Spatie\LaravelData\Lazy;class LazySongData extends Data +use Spatie\LaravelData\Lazy; + +class LazySongData extends Data { public function __construct( - public Lazy|ArristData $artist, + public Lazy|ArtistData $artist, public Lazy|string $title, ) {} } diff --git a/docs/as-a-data-transfer-object/casts.md b/docs/as-a-data-transfer-object/casts.md index 0b9e3d05..470f44a1 100644 --- a/docs/as-a-data-transfer-object/casts.md +++ b/docs/as-a-data-transfer-object/casts.md @@ -160,5 +160,5 @@ ReleaseData::from([ For this feature to work, a cast should not only implement the `Cast` interface but also the `IterableItemCast`. The signatures of the `cast` and `castIterableItem` methods are exactly the same, but they're called on different times. When casting a property like a DateTime from a string, the `cast` method will be used, when transforming an iterable -property like an arrat or Laravel Collection where the iterable item is typed using an annotation, then each item of the +property like an array or Laravel Collection where the iterable item is typed using an annotation, then each item of the provided iterable will trigger a call to the `castIterableItem` method. diff --git a/docs/as-a-resource/wrapping.md b/docs/as-a-resource/wrapping.md index 578fcd8d..d212cbbe 100644 --- a/docs/as-a-resource/wrapping.md +++ b/docs/as-a-resource/wrapping.md @@ -160,7 +160,8 @@ UserData::from(User::first())->wrap('data'); A data collection inside a data object WILL get wrapped when a wrapping key is set: ```php -use Spatie\LaravelData\Attributes\DataCollectionOf;use Spatie\LaravelData\DataCollection; +use Spatie\LaravelData\Attributes\DataCollectionOf; +use Spatie\LaravelData\DataCollection; class AlbumData extends Data {