PHP code inside Laravel 5 Blade Template
问题 I have to place some PHP code inside Laravel 5 Blade Template. Like below @foreach ($farmer->tasks as $task) @if ($task->pivot->due_at) < date(now)) $style = 'alert alert-danger'; @elseif ($task->pivot->due_at) > date(now)) $style = 'alert alert-success'; @else $style = ''; @endif @endforeach Which is the actual procedure to place PHP code inside Laravel 5 Blade Template ?? 回答1: According to documentation, in Laravel 5.2 and newer you can use the following code: @php {{-- php code here --}}