データベースとPermissionsテーブルに 3 つの項目がありますが、このコードは空の配列を返します。ページにエラーはありません。空のドロップダウン メニューしかありません。(私はLaravel 5.4を使用しています)
モデル: Permission.php
protected $fillable = ['name' , 'label'];
public function roles()
{
return $this->belongsToMany(Role::class);
}
controller: (このページ\controllerで問題が発生します)
public function create()
{
return view('Admin.roles.create');
}
ビュー (問題のある部分):
@foreach(\App\Permission::latest()->get() as $permission)
<option value="{{ $permission->id }}">{{$permission->name }} - {{$permission->label }}</option>
@endforeach