Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Z3d0X committed Jan 1, 2025
1 parent d89f44b commit b01f15c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/FilamentFabricatorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getPageUrls(): array

public function getPageUrlFromId(int|string $id, bool $prefixSlash = false, array $args = []): ?string
{
/** @var PageContract&Model|null $page */
/** @var (PageContract&Model)|null $page */
$page = $this->getPageModel()::query()->find($id);

return $page?->getUrl($args);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __invoke(?Page $filamentFabricatorPage = null): string
}

/** @var ?class-string<Layout> $layout */
$layout = FilamentFabricator::getLayoutFromName($filamentFabricatorPage?->layout);
$layout = FilamentFabricator::getLayoutFromName($filamentFabricatorPage->layout);

if (! isset($layout)) {
throw new \Exception("Filament Fabricator: Layout \"{$filamentFabricatorPage->layout}\" not found");
Expand Down
19 changes: 10 additions & 9 deletions src/Services/PageRoutesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,17 @@ protected function getIdToUrisMapping(): array
// Any optimization to this can greatly improve the entire package's performances
// in one fell swoop.
return Cache::rememberForever(static::ID_TO_URI_MAPPING, function () {
$pages = FilamentFabricator::getPageModel()::query()
$mapping = FilamentFabricator::getPageModel()::query()
->with('parent')
->get();

$mapping = [];
$pages->each(function (Page $page) use (&$mapping) {
// Note that this also has the benefits of computing
// the page's local caches.
$mapping[$page->id] = $page->getAllUrls();
});
->get()
->toBase()
->mapWithKeys(function (Page $page):array {

Check failure on line 184 in src/Services/PageRoutesService.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $callback of method Illuminate\Support\Collection<int,Illuminate\Database\Eloquent\Model>::mapWithKeys() expects callable(Illuminate\Database\Eloquent\Model, int): array<int|string, array<string>>, Closure(Z3d0X\FilamentFabricator\Models\Contracts\Page): non-empty-array<int|string, array<string>> given.
// Note that this also has the benefits of computing
// the page's local caches.
// @phpstan-ignore-next-line
return [$page->id => $page->getAllUrls()];

Check failure on line 188 in src/Services/PageRoutesService.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 188.
})
->all();

return $mapping;
});
Expand Down

0 comments on commit b01f15c

Please sign in to comment.