Created a belongsTo relationship called size and it is returning null when called as property, however when calling as function, builder object is returned.
class Product extends Eloquent {
//
function size()
{
return $this->belongsTo(InventorySizes::class, 'inventory_size_id');
}
}
$product->size // returns null
$product->size()->first() // returns Size Model as expected
Hey @jaketoolson, could it be because you have a column on the table with the same name as the property?
@seanmangar son of a... that was it 馃憤 I was going crazy too, checking everything, even my tests yielded the same "bug". Sigh those damn magic properties ;)
Most helpful comment
Hey @jaketoolson, could it be because you have a column on the table with the same name as the property?