1 year ago

Undefined Offset exception when accessing a model's attribute

Posted 1 year ago by braed

I have the following example code:

$exhibitor = Exhibitor::first();
$option = $exhibitor->options()->first();

$option has a price attribute of data type decimal that is not mutated. Accessing it gives a Undefined offset: 1 exception:

$option->price; // throws


Please sign in or create an account to participate in this conversation.