How can I hide widgets?

I want only authorised users to view widgets on the homepage. I am trying to do this with authorisation control but it is still displayed.
3 Replies
Dennis Koch
Dennis Koch2y ago
Do they have a canView() method?
Mehmet K.
Mehmet K.OP2y ago
public static function canView():bool { if(\auth()->user()->can('show_widgets')){ return true; } else{ return false; } } thanks I solved it this way with your guidance.
usmcgator
usmcgator2y ago
piggy backing off this topic. This is exactly what I needed, with one additional step. When both widgets are displayed, I have it set to two columns so the widgets get displayed side by side. When the widget is hidden based on canView(), I'd like to have the remaining widget to have a full span (i.e., protected int | string | array $columnSpan = 'full'). Is there a way to set the $columnSpan value based on logic?
Want results from more Discord servers?
Add your server