i have problem the problem is Where Clause not work in my project, i make sure to follow instruction on laravel documentation but the data in my table is not show on my datatable, i hope you can help me.
AbsenController@index
public function index()
{
$absen = Absen::get()->where('level', '=', 'Siswa');
return view('absen.index')->with('data', $absen);
}
index.blade.php
@foreach($data as $index => $value)
<tr>
<td>{{ $index+1 }}</td>
<td>{{ $value->nama }}</td>
<td>{{ $value->keterangan }}</td>
<td>
{!! Form::open(['route' => ['siswa.destroy', $value->id],
'method' => 'DELETE']) !!}
{{ Form::submit('Hapus', ['class' => 'btn btn-danger']) }}
<a href="{{ route('siswa.edit', $value->id) }}" class="btn
btn-warning">Edit</a>
{!! Form::close() !!}
</td>
</tr>
@endforeach
The record is not showing in my datatable
But i have one record in my table Thanks
答案 0 :(得分:0)
You are fetching records before filtering with where..
You should do:
$absen = Absen::where('level', '=', 'Siswa')->get();
instead.