Switch in Laravel 5 - Blade

后端 未结 8 541
南旧
南旧 2021-02-02 05:10

How can I use switch in blade templates? When I used:

@switch($login_error)
    @case(1)
        `E-mail` input is empty!
        @break
    @case(2)
        `Pa         


        
8条回答
  •  野性不改
    2021-02-02 05:35

    IN LARAVEL 5.2 AND UP:

    Write your usual code between the opening and closing PHP statements.

    @php
    switch (x) {
        case 1:
            //code to be executed
            break;
        default:
            //code to be executed
    }
    @endphp
    

提交回复
热议问题