Skip to content
Advertisement

dropdown is populating empty list in laravel 6

Laravel Version 6. PHP 7.4.

I simply wants to populate my dropdown values form database table. Initially, It was returning error “variable undefined” but when I enclosed my code into if condition, my error was gone but drop-down list is empty.

Please suggest where I’ m stuck.

Route.php

JavaScript

Controller

JavaScript

View

JavaScript

I also tried “dd($records);” but nothing happens.

Advertisement

Answer

First Make sure that your table have data. And then change your controller and view like this.

Controller Code

JavaScript

View Code:

JavaScript

I hope it will help you 🙂

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement