Is the data there if you try a dd?
Feb 2, 2026
8
Level 2
Problem with foreach - array offset on null
Hi,
I've a problem, in my component I've 2 methods :
#[Computed]
public function resourceTypes()
{
return ResourceTypeModel::orderBy('name', 'ASC')->get();
}
#[Computed]
public function periodicityTypes()
{
return PeriodicityTypeModel::orderByRaw("FIELD(reference, 'mensuelle', 'trimestrielle', 'semestrielle', 'annuelle') DESC")->get();
}
In my blade template, I try to use foreach, it doesn't work
<flux:select variant="listbox" placeholder="Choose industry...">
@foreach($this->resourceTypes as $item)
<flux:select.option>{{ $item->name }}</flux:select.option>
@endforeach
</flux:select>
I've this error
Trying to access array offset on null (View: /var/www/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/markdown.blade.php)
If I change resourceTypes by resources in my blade template IT WORKS, I don't what's wrong with resourceTypes !!! If anybody can help ?
Please or to participate in this conversation.