-1

error

I have declared $datas on the controller.

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>
matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
  • 1
    Does this answer your question? [How to pass data to view in Laravel?](https://stackoverflow.com/questions/18341792/how-to-pass-data-to-view-in-laravel) – miken32 Jul 08 '23 at 13:44
  • You clearly didn't even try to read the documentation because it has a dedicated section on the views that literally tells you how to do what you want to do... https://laravel.com/docs/10.x/views#passing-data-to-views – matiaslauriti Jul 08 '23 at 15:54

1 Answers1

-2

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]);
    }
}
Jignesh Sanghani
  • 602
  • 6
  • 12
  • Do not answer to duplicated questions, this question is asked a lot of times per week and are marked as duplicates, and the documentation has a section for this... https://laravel.com/docs/10.x/views#passing-data-to-views – matiaslauriti Jul 08 '23 at 15:55