Badge on Resource Sub-Navigation #10168
Unanswered
diogogpinto
asked this question in
Help
Replies: 4 comments 4 replies
|
This is a workaround I got... not ideal, I suppose, but will wait on you guys' feedback! public static function getNavigationBadge(): ?string
{
return self::getResource()::getModel()::findOrFail(request()->route()->parameter('record'))->notes()->count();
} |
2 replies
|
So far I haven't found any solution to this problem and I don't think there's any other possible solution, because of how the badge is called when browsing other items in the navigation. The only working solution so far is really: public static function getNavigationBadge(): ?string
{
return self::getResource()::getModel()::findOrFail(request()->route()->parameter('record'))->notes()->count();
}I don't know if performance wise o security wise this is safe, though. |
2 replies
|
I know this is an old question, but I found this somewhere else, and I think it is a good approach. |
0 replies
|
Thanks for the wonderful solution @erchecho 👍 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Hello, friends 👋🏻
On a Resource Page, how can you get the count for a relationship?
In this example, my method has a a 'notes" relationship... and in the custom page for that resource, I have the following code:
But I get the following error:
Am I doing something wrong or is this something that can't be done at the moment?
Thank you!
All reactions