在我的控制器中,我从数据库中获取一些值并将它们发送到 Blade View。我通过 检查了我的查询php artisan tinker,它返回了一条有效记录。问题是我的 Blade 视图没有获取从控制器传递的值。
控制器
public function getMake()
{
$records = DB::table('users')->get()->toArray();
return view('products.qrcodes.basic',compact('records'));
}
路线
Route::get('/basicfile', 'niceActionController@getMake');
看法
<select>
<option selected disabled>Make*</option>
@if(empty($records))
Whoops! Something went wrong
@else
@foreach ($records as $key => $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
@endif
</select>
BIG阳
胡说叔叔
互换的青春
饮歌长啸