PHP code inside a Laravel 5 blade template

前端 未结 5 1107
名媛妹妹
名媛妹妹 2020-12-16 09:10

I have to place some PHP code inside a Laravel 5 blade template. Like below

@foreach ($farmer->tasks as $task)
    @if ($task->pivot->due_at) < da         


        
5条回答
  •  星月不相逢
    2020-12-16 09:50

    Laravel recipes suggest a simple, but effective, way to do it without including the PHP tags:

    {{--*/ $var = 'test' /*--}}
    

    {{-- --}} works as a blade comment / and / reverts the effect of comment resulting on

    
    

    The problem is that is longer than including PHP tags :-(

提交回复
热议问题