Undefined variable, how can I ask for help
But I have declared $datas on the controller like this
Controller
class JenisImunisasiController extends Controller
{
public function index() {
$jenis = JenisImunisasi::get();
return view('admin.jenisimunisasi.index', ['jenis_imunisasis' => $jenis]);
}
}
and the view like this
index.blade.php
@foreach ($datas as $key => $data)
<tr>
<th>{{ $datas->firstItem() + $key}}</th>
<th>{{ $data->nama_imun}}</th>
<th>{{ $data->umur }}</th>
<th>
</th>
</tr>
@endforeach
</tbody>
</table>
</div>
<div>
Showing
{{ $datas->firstItem() }}
to
{{ $datas->lastItem() }}
of
{{ $datas->total() }}
Entries
</div>
<div class="fa-pull-right">
{{ $datas->links() }}
</div>
</div>
>Solution :
Here check my code you need to pass key as datas instead of jenis_imunisasis in view function second parametere
class JenisImunisasiController extends Controller
{
public function index()
{
$jenis = JenisImunisasi::get();
return view('admin.jenisimunisasi.index', ['datas' => $jenis]);
}
}