Support the ongoing development of Laravel.io →
Eloquent Views

I have this Eloquent model.

$order = Order::find(1);

When I echo $order->Status; this should throw an Undefined Property Notice because no such property Status exists in the object.

If I do this $order = new stdClass; and echo the same thing I will get the Undefined Property notice.

Why I do not get it in Eloquent models?

The problem is when I pass the $order model to the view if I misspell a property Laravel does not display the error that the property is undefined. When I var_dumb I just get NULL.

Last updated 3 years ago.
0

The reason why of this behevior will be clearer If you take a look at how getAttribute is implemented here https://github.com/illuminate/database/blob/4.2/Eloquent/Model.php

I'm not sure, but maybe you should override that class.

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

lazos99 lazos99 Joined 11 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.