拉拉维尔编辑 尝试读取布尔值上的属性"name"



我正在创建一个带有透视表的laravel crud。但每当我按下编辑键时,我都会收到这个错误:

尝试读取属性";name";在bool 上

在"选项"行。

我有多个子文件夹,希望能够从中进行选择。

<div class="form-group">
<label for="name">{{('Subfolder')}}</label>
<select name="subfolders" class="form-control">
@foreach($subfolders as $subfolder)
<option value="{{$subfolder->name}}"></option>
@endforeach
</select>
</div>

控制器:

$files = File::all();
$fileEdit = File::find($id);
$languages = Language::all();
$tags = Tag::all();
$subfolders = Subfolder::all();

$users = User::all();
$roles = Role::all();
$file_subfolder = File_Subfolder::all();
//  dd($subfolders);
return view('admin.file.index', 
compact('files', 'fileEdit', 'languages', 'tags', 
'subfolders' ,'users', 'roles', 'file_subfolder')
);
}

我的子文件夹DD请求:

IlluminateDatabaseEloquentCollection {#1603 ▼
#items: array:5 [▼
0 => AppModelsSubfolder {#1605 ▶}
1 => AppModelsSubfolder {#1606 ▼
#connection: "mysql"
#table: "subfolder"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:5 [▼
"id" => 2
"name" => "indoor"
"slug" => null
"created_at" => null
"updated_at" => null
]
#original: array:5 [▶]
#changes: []
#casts: []
#classCastCache: []
#attributeCastCache: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: array:1 [▶]
#guarded: array:1 [▶]
}
2 => AppModelsSubfolder {#1607 ▶}
3 => AppModelsSubfolder {#1608 ▶}
4 => AppModelsSubfolder {#1609 ▶}
]
#escapeWhenCastingToString: false

如果我需要添加更多信息,我会很乐意的!

尝试更改如下部分。

<div class="form-group">
<label for="name">{{('Subfolder')}}</label>
<select name="subfolders" class="form-control">
@foreach($subfolders as $folder)
<option value="{{$folder->id}}">{{ $folder->name }}</option>
@endforeach
</select>
</div>```

我通过重新命名$子文件夹来修复错误,因为它已经用于其他

相关内容