generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
Does the library support ResourceCollection?
How to reproduce the bug
I have a ResourceCollection similar to this:
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
/**
* @mixin \App\Models\ModelName
*/
class ResponseResourceCollection extends ResourceCollection
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return $this->collection->transform(fn($item) => $this->transformItem($item))->toArray();
}
protected function transformItem($item): array
{
return [
'id' => $item->id,
];
}
}When running the php artisan runtype:generate command I get this error:
Attempt to read property "id" on array
I also tried changing the mixin to:
/**
* @mixin \Illuminate\Database\Eloquent\Collection<\App\Models\ModelName>
*/but I got this error Undefined property: ReflectionClass::$id
Package Version
0.3.1
PHP Version
8.3.19
Laravel Version
11.0.0
Which operating systems does with happen with?
Windows
Notes
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working