我为我的代码语法的混乱布局道歉,也许我真的不明白如何使用@forelse
和@if
在 Laravel 中,这个代码结果是
语法错误,意外的 'endif' (T_ENDIF)
<tbody>
@forelse ($kaders as $kader)
<tr>
<td>{{ $kader->username }}</td>
@if($kader->status_user == '1')
<td>Admin</td>
@elseif($kader->status_user == '0')
<td>Ibu / Guest</td>
@endif
@forelse ($surveillances as $surveillance)
@if($kader->username == $surveillance->nik_ortu)
@if($surveillance->status == '1')
<td>Aktif</td>
@elseif($surveillance->status == '0')
<td>NonAKtif</td>
@endif
@endif
@endforelse
<td class="text-center">
<form onsubmit="return confirm('Apakah Anda Yakin ?');" action="{{ route('kader.destroy', $kader->id) }}" method="POST">
<a href="{{ route('kader.edit', $kader->id) }}" class="btn btn-sm btn-primary"><i class="far fa-edit"></i> EDIT</a>
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger"><i class="far fa-trash-alt"></i> HAPUS</button>
</form>
</td>
</tr>
@empty
<div class="alert alert-danger">
Data Kader belum Tersedia.
</div>
@endforelse
</tbody>