diff --git a/CHANGELOG.md b/CHANGELOG.md index ef0c1a0..5a32411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. [Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v2.13.0...master) -------------- +### Added +- Add support for `immutable_date:*` and `immutable_datetime:*` casts. [#1380 / thekonz](https://github.com/barryvdh/laravel-ide-helper/pull/1380) + 2023-02-04, 2.13.0 ------------------ diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 8b29612..308a11f 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -369,6 +369,10 @@ class ModelsCommand extends Command $type = 'date'; } elseif (Str::startsWith($type, 'immutable_custom_datetime:')) { $type = 'immutable_date'; + } elseif (Str::startsWith($type, 'immutable_date:')) { + $type = 'immutable_date'; + } elseif (Str::startsWith($type, 'immutable_datetime:')) { + $type = 'immutable_datetime'; } elseif (Str::startsWith($type, 'encrypted:')) { $type = Str::after($type, ':'); } diff --git a/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php b/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php index 420ab74..e96b673 100644 --- a/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php +++ b/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php @@ -28,8 +28,10 @@ class SimpleCast extends Model 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', 'cast_to_immutable_date' => 'immutable_date', + 'cast_to_immutable_date_serialization' => 'immutable_date:Y-m-d', 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', 'cast_to_immutable_datetime' => 'immutable_datetime', + 'cast_to_immutable_datetime_serialization' => 'immutable_datetime:Y-m-d H:i:s', 'cast_to_timestamp' => 'timestamp', 'cast_to_encrypted' => 'encrypted', 'cast_to_encrypted_array' => 'encrypted:array', diff --git a/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php index ea2617a..91a4511 100644 --- a/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php @@ -28,8 +28,10 @@ use Illuminate\Database\Eloquent\Model; * @property \Illuminate\Support\Carbon $cast_to_datetime_serialization * @property \Illuminate\Support\Carbon $cast_to_custom_datetime * @property \Carbon\CarbonImmutable $cast_to_immutable_date + * @property \Carbon\CarbonImmutable $cast_to_immutable_date_serialization * @property \Carbon\CarbonImmutable $cast_to_immutable_custom_datetime * @property \Carbon\CarbonImmutable $cast_to_immutable_datetime + * @property \Carbon\CarbonImmutable $cast_to_immutable_datetime_serialization * @property integer $cast_to_timestamp * @property mixed $cast_to_encrypted * @property array $cast_to_encrypted_array @@ -58,7 +60,9 @@ use Illuminate\Database\Eloquent\Model; * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToFloat($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToImmutableCustomDatetime($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToImmutableDate($value) + * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToImmutableDateSerialization($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToImmutableDatetime($value) + * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToImmutableDatetimeSerialization($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToInt($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToInteger($value) * @method static \Illuminate\Database\Eloquent\Builder|SimpleCast whereCastToJson($value) @@ -90,8 +94,10 @@ class SimpleCast extends Model 'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s', 'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s', 'cast_to_immutable_date' => 'immutable_date', + 'cast_to_immutable_date_serialization' => 'immutable_date:Y-m-d', 'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s', 'cast_to_immutable_datetime' => 'immutable_datetime', + 'cast_to_immutable_datetime_serialization' => 'immutable_datetime:Y-m-d H:i:s', 'cast_to_timestamp' => 'timestamp', 'cast_to_encrypted' => 'encrypted', 'cast_to_encrypted_array' => 'encrypted:array', diff --git a/tests/Console/ModelsCommand/migrations/____simple_casts_table.php b/tests/Console/ModelsCommand/migrations/____simple_casts_table.php index d83a551..6ab866f 100644 --- a/tests/Console/ModelsCommand/migrations/____simple_casts_table.php +++ b/tests/Console/ModelsCommand/migrations/____simple_casts_table.php @@ -30,8 +30,10 @@ class SimpleCastsTable extends Migration $table->string('cast_to_datetime_serialization'); $table->string('cast_to_custom_datetime'); $table->string('cast_to_immutable_date'); + $table->string('cast_to_immutable_date_serialization'); $table->string('cast_to_immutable_custom_datetime'); $table->string('cast_to_immutable_datetime'); + $table->string('cast_to_immutable_datetime_serialization'); $table->string('cast_to_timestamp'); $table->string('cast_to_encrypted'); $table->string('cast_to_encrypted_array');