feat: add support for AsCollection and AsArrayObject casts (#1393)

* feat: add support for AsCollection and AsArrayObject casts

* update changelog

* improve tests

* remove change

* composer fix-style

* snapshot

---------

Co-authored-by: Barry vd. Heuvel <[email protected]>
Co-authored-by: laravel-ide-helper <[email protected]>
This commit is contained in:
Pieter Willekens
2024-02-08 10:59:02 +01:00
committed by GitHub
co-authored by Barry vd. Heuvel laravel-ide-helper
parent cee441c87c
commit 341c0ab89f
6 changed files with 162 additions and 0 deletions
+6
View File
@@ -23,6 +23,8 @@ use Illuminate\Console\Command;
use Illuminate\Contracts\Database\Eloquent\Castable;
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\Attribute;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Model;
@@ -419,9 +421,13 @@ class ModelsCommand extends Command
case 'immutable_datetime':
$realType = '\Carbon\CarbonImmutable';
break;
case AsCollection::class:
case 'collection':
$realType = '\Illuminate\Support\Collection';
break;
case AsArrayObject::class:
$realType = '\ArrayObject';
break;
default:
// In case of an optional custom cast parameter , only evaluate
// the `$type` until the `:`