Support the ongoing development of Laravel.io →
Views Blade
Last updated 2 years ago.
0

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;
}
0

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.

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

balkanjero balkanjero Joined 26 Apr 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.