Why PHP variable not recognize in blade @if condition?
Hello!
Try to filter by day...
@php
$dn = date('N', strtotime($days)); // 1
@endphp
@foreach ($program->exercises as $exercise )
@if ( $exercise->pivot->day_of_week === $dn )
{{ $exercise->name }}<br>
@endif
@endforeach
outputs nothing
but if i replace the variable with a digit
@php
$dn = date('N', strtotime($days)); // 1
@endphp
@foreach ($program->exercises as $exercise )
@if ( $exercise->pivot->day_of_week === 1 )
{{ $exercise->name }}<br>
@endif
@endforeach
exercises are shown...
Whats wrong with $dn variable?
@michaloravec
exactly! Thanks a lot!
spent an hour looking for an error...
Why not also lose the temporary variable?
@foreach ($program->exercises as $exercise )
@if ( $exercise->pivot->day_of_week == date('N', strtotime($days)) )
{{ $exercise->name }}<br>
@endif
@endforeach
@snapey
That better. Thanks for the advice!
Please or to participate in this conversation.