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
Route::get('products/qrcodes/basic','niceActionController@getMake');
Controller
<?php
namespace App\Http\Controllers;
use \Illuminate\Http\Request;
use App\NiceAction;
use App\NiceActionLogged;
public function getMake()
{
$records = DB::table('users')->get();
return view('products.qrcodes.basic', ['records' => $records]);
}
View
<form>
<select required>
@if ((empty($records)))
Whoops! Something went wrong
@else
@foreach ($records as $item)
<option value=""></option>
@endforeach
@endif
</select>
</form>
I also tried "dd($records);" but nothing happens.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire