diff --git a/CHANGELOG.md b/CHANGELOG.md index 30604d8..dfddbbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,9 @@ All notable changes to this project will be documented in this file. ### Added - Add type to pivot when using a custom pivot class [#1518 / d3v2a](https://github.com/barryvdh/laravel-ide-helper/pull/1518) + - Add support for AsEnumCollection casts [#1557 / Braunson](https://github.com/barryvdh/laravel-ide-helper/pull/1557) - Support for Attribute class in attributes [#1567 / stefanScrumble](https://github.com/barryvdh/laravel-ide-helper/pull/1567) - 2024-03-01, 3.0.0 ------------------ @@ -27,7 +27,7 @@ All notable changes to this project will be documented in this file. - Use short types (`int` and `bool` instead of `integer` and `boolean`) [#1524 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1524) ### Removed -- Support for Laravel 9 and use of doctrine/dbal [#1512 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1512) +- Support for Laravel 9 and use of doctrine/dbal [#1512 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1512) With this functionality gone, a few changes have been made: - support for custom datatypes has been dropped (config `custom_db_types`) unknown data types default to `string` now and to fix the type, add a proper cast in Eloquent - You _might_ have top-level dependency on doctrine/dbal. This may have been in the past due to ide-helper, we suggest to check if you still need it and remove it otherwise @@ -91,7 +91,7 @@ All notable changes to this project will be documented in this file. - Handle PHP 8.1 deprecation warnings when passing `null` to `new \ReflectionClass` [#1351 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1351) - Fix issue where \Eloquent is not included when using write_mixin [#1352 / Jefemy](https://github.com/barryvdh/laravel-ide-helper/pull/1352) - Fix model factory method arguments for Laravel >= 9 [#1361 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1361) -- Improve return type of mock helper methods in tests [#1405 / bentleyo](https://github.com/barryvdh/laravel-ide-helper/pull/1405) +- Improve return type of mock helper methods in tests [#1405 / bentleyo](https://github.com/barryvdh/laravel-ide-helper/pull/1405) - Fix Castable class if failed to detect it from return types [#1388 / kwarcu](https://github.com/barryvdh/laravel-ide-helper/pull/1388) ### Added diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index a43021c..818606c 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -24,6 +24,7 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; use Illuminate\Database\Eloquent\Casts\AsArrayObject; use Illuminate\Database\Eloquent\Casts\AsCollection; +use Illuminate\Database\Eloquent\Casts\AsEnumCollection; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Model; @@ -409,6 +410,7 @@ class ModelsCommand extends Command $realType = '\Carbon\CarbonImmutable'; break; case AsCollection::class: + case AsEnumCollection::class: case 'collection': $realType = '\Illuminate\Support\Collection'; break; diff --git a/tests/Console/ModelsCommand/AdvancedCasts/Models/AdvancedCast.php b/tests/Console/ModelsCommand/AdvancedCasts/Models/AdvancedCast.php index 4613056..4f1f176 100644 --- a/tests/Console/ModelsCommand/AdvancedCasts/Models/AdvancedCast.php +++ b/tests/Console/ModelsCommand/AdvancedCasts/Models/AdvancedCast.php @@ -6,6 +6,7 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Mo use Illuminate\Database\Eloquent\Casts\AsArrayObject; use Illuminate\Database\Eloquent\Casts\AsCollection; +use Illuminate\Database\Eloquent\Casts\AsEnumCollection; use Illuminate\Database\Eloquent\Model; class AdvancedCast extends Model @@ -24,6 +25,7 @@ class AdvancedCast extends Model 'cast_to_encrypted_json' => 'encrypted:json', 'cast_to_encrypted_object' => 'encrypted:object', 'cast_to_as_collection' => AsCollection::class, + 'cast_to_as_enum_collection' => AsEnumCollection::class, 'cast_to_as_array_object' => AsArrayObject::class, ]; } diff --git a/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php index 2c29482..9c9972a 100644 --- a/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php @@ -6,6 +6,7 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Mo use Illuminate\Database\Eloquent\Casts\AsArrayObject; use Illuminate\Database\Eloquent\Casts\AsCollection; +use Illuminate\Database\Eloquent\Casts\AsEnumCollection; use Illuminate\Database\Eloquent\Model; /** @@ -24,12 +25,14 @@ use Illuminate\Database\Eloquent\Model; * @property array $cast_to_encrypted_json * @property object $cast_to_encrypted_object * @property \Illuminate\Support\Collection $cast_to_as_collection + * @property \Illuminate\Support\Collection $cast_to_as_enum_collection * @property \ArrayObject $cast_to_as_array_object * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast newQuery() * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast query() * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToAsArrayObject($value) * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToAsCollection($value) + * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToAsEnumCollection($value) * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToCustomDatetime($value) * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToDateSerialization($value) * @method static \Illuminate\Database\Eloquent\Builder|AdvancedCast whereCastToDatetimeSerialization($value) @@ -60,6 +63,7 @@ class AdvancedCast extends Model 'cast_to_encrypted_json' => 'encrypted:json', 'cast_to_encrypted_object' => 'encrypted:object', 'cast_to_as_collection' => AsCollection::class, + 'cast_to_as_enum_collection' => AsEnumCollection::class, 'cast_to_as_array_object' => AsArrayObject::class, ]; } diff --git a/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php b/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php index e96b673..b9ce9ae 100644 --- a/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php +++ b/tests/Console/ModelsCommand/SimpleCasts/Models/SimpleCast.php @@ -22,6 +22,7 @@ class SimpleCast extends Model 'cast_to_array' => 'array', 'cast_to_json' => 'json', 'cast_to_collection' => 'collection', + 'cast_to_enum_collection' => 'collection', 'cast_to_date' => 'date', 'cast_to_datetime' => 'datetime', 'cast_to_date_serialization' => 'date:Y-m-d', diff --git a/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php index cfcec0b..257a55d 100644 --- a/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php @@ -88,6 +88,7 @@ class SimpleCast extends Model 'cast_to_array' => 'array', 'cast_to_json' => 'json', 'cast_to_collection' => 'collection', + 'cast_to_enum_collection' => 'collection', 'cast_to_date' => 'date', 'cast_to_datetime' => 'datetime', 'cast_to_date_serialization' => 'date:Y-m-d', diff --git a/tests/Console/ModelsCommand/migrations/____advanced_casts_table.php b/tests/Console/ModelsCommand/migrations/____advanced_casts_table.php index 3c6a392..364d5b9 100644 --- a/tests/Console/ModelsCommand/migrations/____advanced_casts_table.php +++ b/tests/Console/ModelsCommand/migrations/____advanced_casts_table.php @@ -24,6 +24,7 @@ class AdvancedCastsTable extends Migration $table->string('cast_to_encrypted_json'); $table->string('cast_to_encrypted_object'); $table->string('cast_to_as_collection'); + $table->string('cast_to_as_enum_collection'); $table->string('cast_to_as_array_object'); }); }