F
Filament7mo ago
Jakub

custom pages not being detected

Following these docs: https://filamentphp.com/docs/3.x/panels/resources/custom-pages I was able to make everything work on Project A so I understand I need to add them to getPages(), i created an extra settings one just to make sure im not hallucinating and I did get it working Project A - AdminPanelProvider
public static function getPages(): array
{
return [
'index' => Pages\ManageTasks::route('/'),
'schedule' => Pages\TeamSchedules::route('/team-schedules'),
'settings' => Pages\Settings::route('/settings'),
];
}

// i did register the team schedules on the panel and it works on this project
->pages([
Pages\Dashboard::class,
\App\Filament\Resources\TaskResource\Pages\TeamSchedules::class,
])
public static function getPages(): array
{
return [
'index' => Pages\ManageTasks::route('/'),
'schedule' => Pages\TeamSchedules::route('/team-schedules'),
'settings' => Pages\Settings::route('/settings'),
];
}

// i did register the team schedules on the panel and it works on this project
->pages([
Pages\Dashboard::class,
\App\Filament\Resources\TaskResource\Pages\TeamSchedules::class,
])
Project B - ManagePanelProvider The only difference that I can see is that I did not use admin, but the word manage.
// resigstered the pages on panel
->pages([
Pages\Dashboard::class,
\App\Filament\Resources\PhoneMembershipResource\Pages\OverduePhoneMemberships::class,
])

// and on the resource
public static function getPages(): array
{
return [
'index' => Pages\ListPhoneMemberships::route('/'),
'create' => Pages\CreatePhoneMembership::route('/create'),
'view' => Pages\ViewPhoneMembership::route('/{record}'),
'overdue'=> Pages\OverduePhoneMemberships::route('/overdue'),
'settings'=> Pages\Settings::route('/settings'),
// 'edit' => Pages\EditPhoneMembership::route('/{record}/edit'),
];
}
// resigstered the pages on panel
->pages([
Pages\Dashboard::class,
\App\Filament\Resources\PhoneMembershipResource\Pages\OverduePhoneMemberships::class,
])

// and on the resource
public static function getPages(): array
{
return [
'index' => Pages\ListPhoneMemberships::route('/'),
'create' => Pages\CreatePhoneMembership::route('/create'),
'view' => Pages\ViewPhoneMembership::route('/{record}'),
'overdue'=> Pages\OverduePhoneMemberships::route('/overdue'),
'settings'=> Pages\Settings::route('/settings'),
// 'edit' => Pages\EditPhoneMembership::route('/{record}/edit'),
];
}
Solution:
```php public static function getPages(): array { return [ 'index' => Pages\ListTasks::route('/'),...
Jump to solution
36 Replies
Jakub
JakubOP7mo ago
In the sidebar for project b. I do see the overdue accounts page showing up
No description
Jakub
JakubOP7mo ago
<?php

namespace App\Filament\Resources\PhoneMembershipResource\Pages;

use App\Filament\Resources\PhoneMembershipResource;
use App\Models\PhoneMembership;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class OverduePhoneMemberships extends ListRecords
{
protected static string $resource = PhoneMembershipResource::class;


protected static ?string $navigationLabel = 'Overdue Accounts';


protected static ?int $navigationSort = 1;

protected static ?string $navigationGroup = 'T-Mobile Plans';

public static function getNavigationBadge(): ?string
{
$count = PhoneMembership::whereHas('phoneMembershipRecords', function ($query) {
$query->whereHas('phoneMembership', function ($query) {
$query->whereRaw('(SELECT SUM(value) FROM phone_membership_records WHERE type = 1 AND phone_membership_id = phone_memberships.id) - (SELECT SUM(value) FROM phone_membership_records WHERE type = 2 AND phone_membership_id = phone_memberships.id) < 0');
});
})->where('is_free', false)->where('is_subscriber', false)->count();
return $count == 0 ? null : (string)$count;
}

public static function getNavigationBadgeColor(): ?string
{
return 'danger';
}
}
<?php

namespace App\Filament\Resources\PhoneMembershipResource\Pages;

use App\Filament\Resources\PhoneMembershipResource;
use App\Models\PhoneMembership;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class OverduePhoneMemberships extends ListRecords
{
protected static string $resource = PhoneMembershipResource::class;


protected static ?string $navigationLabel = 'Overdue Accounts';


protected static ?int $navigationSort = 1;

protected static ?string $navigationGroup = 'T-Mobile Plans';

public static function getNavigationBadge(): ?string
{
$count = PhoneMembership::whereHas('phoneMembershipRecords', function ($query) {
$query->whereHas('phoneMembership', function ($query) {
$query->whereRaw('(SELECT SUM(value) FROM phone_membership_records WHERE type = 1 AND phone_membership_id = phone_memberships.id) - (SELECT SUM(value) FROM phone_membership_records WHERE type = 2 AND phone_membership_id = phone_memberships.id) < 0');
});
})->where('is_free', false)->where('is_subscriber', false)->count();
return $count == 0 ? null : (string)$count;
}

public static function getNavigationBadgeColor(): ?string
{
return 'danger';
}
}
Its even doing the navigation badge correctly
Jakub
JakubOP7mo ago
I see that it is being registered in the routes
No description
Jakub
JakubOP7mo ago
For additional testing,. the Settings.php page on both projects is just a custom one
<?php

namespace App\Filament\Resources\PhoneMembershipResource\Pages;

use App\Filament\Resources\PhoneMembershipResource;
use Filament\Resources\Pages\Page;

class Settings extends Page
{
protected static string $resource = PhoneMembershipResource::class;

protected static string $view = 'filament.resources.phone-membership-resource.pages.settings';
}
<?php

namespace App\Filament\Resources\PhoneMembershipResource\Pages;

use App\Filament\Resources\PhoneMembershipResource;
use Filament\Resources\Pages\Page;

class Settings extends Page
{
protected static string $resource = PhoneMembershipResource::class;

protected static string $view = 'filament.resources.phone-membership-resource.pages.settings';
}
And I can't access it on the ManagePanelProvider project, but it does work on the one that is AdminPanelProvider Now I am failry confident, and also hopeing that this is not the reason why its not working lol Geuninly am blanking on what I could have done, for none of the custo mpages to work I have reached a point where il send $50 on paypal for help, i spent way to many hours on this haha 🙏 The URL i am trying to access is
http://website.test/manage/phone-memberships/settings
http://website.test/manage/phone-memberships/overdue
http://website.test/manage/phone-memberships/settings
http://website.test/manage/phone-memberships/overdue
But when i do the /settings on the other project, it does work. And once more, yes. I did create the /settings page on the other project 5 min ago, to double check that I can get it working. So I am not totally incompetent lol error I am getting 404 | Not Found Nothing is being added rto the laravel log file either
Jakub
JakubOP7mo ago
and for proof, i did get it working on the other project lol
No description
Jakub
JakubOP7mo ago
littearlly blank page, and idk what I am doing different, since its littearly 1 command and adding to resoruce I just tried it on another project where the panel is called Agency and it doesnt work either seems it only works on Admin? i dont understand
toeknee
toeknee7mo ago
Have you added the rendering code to the view page?
Jakub
JakubOP7mo ago
public static function getPages(): array
{
return [
'index' => Pages\ListTasks::route('/'),
'create' => Pages\CreateTask::route('/create'),
'view' => Pages\ViewTask::route('/{record}'),
'edit' => Pages\EditTask::route('/{record}/edit'),
'inbox' => Pages\Inbox::route('/inbox')
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListTasks::route('/'),
'create' => Pages\CreateTask::route('/create'),
'view' => Pages\ViewTask::route('/{record}'),
'edit' => Pages\EditTask::route('/{record}/edit'),
'inbox' => Pages\Inbox::route('/inbox')
];
}
Littearlly jsut gnerated it as a ListRecord did nothing else, trying to go to the url and it doesnt work, but on the other project where the panel is admin name, everything work when i make the same page Like in the getPages?
Jakub
JakubOP7mo ago
It works on another app where I have the /admin/ route name but any project where i didint call it admin, noen of the custom pages work
No description
Jakub
JakubOP7mo ago
No description
Jakub
JakubOP7mo ago
i remadet he project, called the panel agency, now i cant do anything custom 😦 but it shows up in routes and e verything
toeknee
toeknee7mo ago
Sorry struggling to keep track of everything you are saying. Is there a page that's not registering in your new app? but you can access it directly?
Jakub
JakubOP7mo ago
Okay so, I have 2 projects. They both are essentially the same. Project A< when i was installing filament. I used the name admin the suggested one. When I do the commands to create custom pages for ListRecords ect, and add it to getPages() everything works as intented. No issues, its perfect. Other Projects, when I install filament and call the panel manage agency or anything but admin i dod the commands to the custom pages, the same exact ones. And none of them work across 3 projects now. I do the command to view routs, and its reigstered and shows up. I can even add to the navigation sidebar on the side and it will show the badge icons and stats. But when u click on it, the urlr throws 404
toeknee
toeknee7mo ago
And you ran a php artisan cache:clear
Jakub
JakubOP7mo ago
I can dd dd(TaskResource::getUrl('inbox')); And it shows
http://breezypixels-dashboard.test/agency/tasks/inbox
http://breezypixels-dashboard.test/agency/tasks/inbox
and i go to that page nad its 404 hmm let me try that 😅
toeknee
toeknee7mo ago
Ok, as a random test, add a canView function to that page and set it to true
Jakub
JakubOP7mo ago
naa doesnt work, still get 404 after cache clear, i did route clear stuff too
toeknee
toeknee7mo ago
theory that should trigger a 403 but worth a try
Jakub
JakubOP7mo ago
one moment
<?php

namespace App\Filament\Resources\TaskResource\Pages;

use App\Filament\Resources\TaskResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class Inbox extends ListRecords
{
protected static string $resource = TaskResource::class;

public static function canView(): bool
{
return true;
}
}
<?php

namespace App\Filament\Resources\TaskResource\Pages;

use App\Filament\Resources\TaskResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class Inbox extends ListRecords
{
protected static string $resource = TaskResource::class;

public static function canView(): bool
{
return true;
}
}
Jakub
JakubOP7mo ago
No description
Jakub
JakubOP7mo ago
But if i go to the other project I just ran the command to make inbox page. Just registered it, nothing else
public static function getPages(): array
{
return [
'index' => Pages\ManageTasks::route('/'),
'schedule' => Pages\TeamSchedules::route('/team-schedules'),
'settings' => Pages\Settings::route('/settings'),
'inbox' => Pages\Inbox::route('/inbox'),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ManageTasks::route('/'),
'schedule' => Pages\TeamSchedules::route('/team-schedules'),
'settings' => Pages\Settings::route('/settings'),
'inbox' => Pages\Inbox::route('/inbox'),
];
}
Jakub
JakubOP7mo ago
No description
Jakub
JakubOP7mo ago
only diffrence is admin vs agency lol
toeknee
toeknee7mo ago
What version of filament?
Jakub
JakubOP7mo ago
3.2.73
Jakub
JakubOP7mo ago
No description
toeknee
toeknee7mo ago
Is the page added into the new panels folder? or the admin folder?
Jakub
JakubOP7mo ago
Just on the TaskResource getPages for both projects
Solution
awcodes
awcodes7mo ago
public static function getPages(): array
{
return [
'index' => Pages\ListTasks::route('/'),
'create' => Pages\CreateTask::route('/create'),
'view' => Pages\ViewTask::route('/{record}'),
'edit' => Pages\EditTask::route('/{record}/edit'),
'inbox' => Pages\Inbox::route('/inbox') <-- move this above the 'view' item
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListTasks::route('/'),
'create' => Pages\CreateTask::route('/create'),
'view' => Pages\ViewTask::route('/{record}'),
'edit' => Pages\EditTask::route('/{record}/edit'),
'inbox' => Pages\Inbox::route('/inbox') <-- move this above the 'view' item
];
}
Jakub
JakubOP7mo ago
omg how wow lol
awcodes
awcodes7mo ago
it's looking for a 'record' with the key of 'inbox'
Jakub
JakubOP7mo ago
dude you are a meistro
awcodes
awcodes7mo ago
it's the same as normal route files, the order still matters. 🙂
Jakub
JakubOP7mo ago
im going to remember this forever haha, tytytyty so much for the help with this wow
awcodes
awcodes7mo ago
no worries, happens to us all
Jakub
JakubOP7mo ago
I had to take out to dogo today to solve this haha was going in circles going through both projects, genuinely lostt on what is happening
Want results from more Discord servers?
Add your server