Undefined array key 1

i am getting this error when trying to clear config, route etc. i don't know how to solve it. Anyone got any ideas?
Undefined array key 1

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "C:\xampp\htdocs\nextxlfabricator\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
Undefined array key 1

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "C:\xampp\htdocs\nextxlfabricator\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
11 Replies
raheel3031
raheel3031OP4w ago
anyone?
Matthew
Matthew4w ago
Since this has to do with #z3d0x-fabricator, its best to ask that question there
raheel3031
raheel3031OP4w ago
Noone answers there I have asked the question there
Matthew
Matthew4w ago
ah I see... Im not sure to be honest. Maybe remove the package, clear and download again? Be careful with that though Im not sure what the package does Also, its been less than 2 hours since you asked. Have some patience and someone will respond. I saw that the github repo is still actively maintained, so its very likely that the package creator or someone else will respond
raheel3031
raheel3031OP4w ago
yes thanks. i am also getting this error
Z3d0X\FilamentFabricator\PageBlocks\PageBlock::preloadRelatedData(): Argument #1 ($page) must be of type Z3d0X\FilamentFabricator\Models\Contracts\Page, null given, called in C:\xampp\htdocs\nextxlfabricator\storage\framework\views\7bc23af4b28fbaa47e8a0267dacb0daa.php on line 45
Z3d0X\FilamentFabricator\PageBlocks\PageBlock::preloadRelatedData(): Argument #1 ($page) must be of type Z3d0X\FilamentFabricator\Models\Contracts\Page, null given, called in C:\xampp\htdocs\nextxlfabricator\storage\framework\views\7bc23af4b28fbaa47e8a0267dacb0daa.php on line 45
Undefined array key 6

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 6", "C:\xampp\htdocs\nextxlfabricator\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
Undefined array key 6

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 6", "C:\xampp\htdocs\nextxlfabricator\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
anyone knows what is going on?
Ava
Ava4w ago
Good Morning @raheel3031 - I am gonna throw my two cents in and you can take it for what you think its worth. It seems to me when reading the code you posted that the error is with $urls = $idToUrlsMapping[$page->id]; Maybe update your code to have a fallback if $page->id is missing.
if (isset($idToUrlsMapping[$page->id])) {
$urls = $idToUrlsMapping[$page->id];
$idToUrlsMapping[$page->id] = null;
unset($idToUrlsMapping[$page->id]);
$this->replaceIdToUriMapping($idToUrlsMapping);
} else {
// Handle missing ID gracefully
logger()->warning("Page ID {$page->id} not found in ID to URLs Mapping.");
}
if (isset($idToUrlsMapping[$page->id])) {
$urls = $idToUrlsMapping[$page->id];
$idToUrlsMapping[$page->id] = null;
unset($idToUrlsMapping[$page->id]);
$this->replaceIdToUriMapping($idToUrlsMapping);
} else {
// Handle missing ID gracefully
logger()->warning("Page ID {$page->id} not found in ID to URLs Mapping.");
}
Again this was just my two cent when looking at what you provided. Edit: If you wrong your code with 3x ` then its easier to read. The error might be triggered turing Config/Route clearing because the removeUrlsOf() method is invoked during route clearing, likely via:
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
Make sure the Page models that are being passed exist and are valid.
raheel3031
raheel3031OP4w ago
again this error
Undefined array key 1

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "C:\xampp\htdocs\InventoryManagement\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
Undefined array key 1

at vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
83▕ public function removeUrlsOf(Page $page): void
84▕ {
85▕ // First remove the entries from the (ID -> URI) mapping
86▕ $idToUrlsMapping = $this->getIdToUrisMapping();
➜ 87▕ $urls = $idToUrlsMapping[$page->id];
88▕ $idToUrlsMapping[$page->id] = null;
89▕ unset($idToUrlsMapping[$page->id]);
90▕ $this->replaceIdToUriMapping($idToUrlsMapping);
91▕

1 vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php:87
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "C:\xampp\htdocs\InventoryManagement\vendor\z3d0x\filament-fabricator\src\Services\PageRoutesService.php")

2 vendor\z3d0x\filament-fabricator\src\Commands\ClearRoutesCacheCommand.php:47
Z3d0X\FilamentFabricator\Services\PageRoutesService::removeUrlsOf(Object(Z3d0X\FilamentFabricator\Models\Page))
am i having only this problem? no one else that is having this problem all of a sudden?
LeandroFerreira
GitHub
Update PageRoutesService.php by rezadindar · Pull Request #196 · Z3...
For Fix This Error On Run "php artisan optimize:clear" And Run "php artisan optimize" Again `ErrorException Undefined array key 1 at vendor\z3d0x\filament-fabric...
raheel3031
raheel3031OP4w ago
Running optimize clear and optimize? This would fix it temporarily. There is a problem in the package.
LeandroFerreira
try to open an issue here
GitHub
Issues · Z3d0X/filament-fabricator
Block-Based Page Builder Skeleton for your Filament Apps - Issues · Z3d0X/filament-fabricator
raheel3031
raheel3031OP4w ago
Thanks for your help. I placed the issue two days ago on the forum as well.

Did you find this page helpful?