Badge on Resource Sub-Navigation #10168
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();
} |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
I know this is an old question, but I found this somewhere else, and I think it is a good approach.
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the wonderful solution @erchecho 👍 |
Beta Was this translation helpful? Give feedback.
-
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!
Beta Was this translation helpful? Give feedback.
All reactions