i am creating a laravel crud with pivot tables. but whenever i press on edit i get this error:
Attempt to read property "name" on bool
on the ‘option’ line.
i have multiple subfolders i want to be able to select from.
<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>
controller:
$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')
);
}
my subfolders DD request:
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
if i need to add more information i will gladly do so!
2
Answers
i fixed the error by re nameing the $subfolders as it was already used for something else
try to change the section like below.