I don't completly follow but if you are going to use switch, you need break before you define a new case, like this
switch (n) {
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
case label3:
code to be executed if n=label3;
break;
...
default:
code to be executed if n is different from all labels;
}
In your controller method you pass the display mode to the template:
public function index()
{
...
return view('index', [
'displayMode' => $displayMode
]);
}
Blade does not support any switch statement. So you better use if-else-statements or plain PHP. For plain PHP @muppbarn already gave a good example.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community