Update to laravel-data 4.0

This commit is contained in:
philipp lang 2024-09-22 00:25:49 +02:00
parent b735186c2d
commit 565cf2b158
5 changed files with 10 additions and 5 deletions

View File

@ -7,6 +7,7 @@ use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Casts\DateTimeInterfaceCast;
use Spatie\LaravelData\Casts\Uncastable;
use Spatie\LaravelData\Exceptions\CannotCastDate;
use Spatie\LaravelData\Support\Creation\CreationContext;
use Spatie\LaravelData\Support\DataProperty;
class CarbonCast implements Cast
@ -19,7 +20,7 @@ class CarbonCast implements Cast
/**
* @param array<string, mixed> $context
*/
public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null
{
if ($property->type->isNullable && !$value) {
return null;

View File

@ -3,6 +3,7 @@
namespace Zoomyboy\LaravelNami\Casters;
use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Support\Creation\CreationContext;
use Spatie\LaravelData\Support\DataProperty;
class GroupCast implements Cast
@ -14,7 +15,7 @@ class GroupCast implements Cast
/**
* @param array<string, mixed> $context
*/
public function cast(DataProperty $property, mixed $value, array $context): ?string
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
{
if ($property->type->isNullable && !$value) {
return null;

View File

@ -5,6 +5,7 @@ namespace Zoomyboy\LaravelNami\Casters;
use DateTimeInterface;
use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Casts\Uncastable;
use Spatie\LaravelData\Support\Creation\CreationContext;
use Spatie\LaravelData\Support\DataProperty;
class NullValueCast implements Cast
@ -17,7 +18,7 @@ class NullValueCast implements Cast
/**
* @param array<string, mixed> $context
*/
public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null|int
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null|int
{
if ($this->id === $value) {
return null;

View File

@ -3,6 +3,7 @@
namespace Zoomyboy\LaravelNami\Casters;
use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Support\Creation\CreationContext;
use Spatie\LaravelData\Support\DataProperty;
class StringCast implements Cast
@ -14,7 +15,7 @@ class StringCast implements Cast
/**
* @param array<string, mixed> $context
*/
public function cast(DataProperty $property, mixed $value, array $context): ?string
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string
{
if ($property->type->isNullable && !$value) {
return null;

View File

@ -3,6 +3,7 @@
namespace Zoomyboy\LaravelNami\Transformers;
use Spatie\LaravelData\Support\DataProperty;
use Spatie\LaravelData\Support\Transformation\TransformationContext;
use Spatie\LaravelData\Transformers\Transformer;
class CarbonTransformer implements Transformer
@ -12,7 +13,7 @@ class CarbonTransformer implements Transformer
) {
}
public function transform(DataProperty $property, mixed $value): mixed
public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed
{
if (is_null($value)) {
return null;