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
Do they have a
canView()
method?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.
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?