lundi 11 janvier 2016

Laravel - Make throw exception when trying to access attribute which is not in select

For example a model has a lot of attributes, but in select I specify only a few.

$listings = Realty::select('city', 'mls', 'class_id')->get();

How to make a trait (prefebable) or class inherits Eloquent which will throw exception if I try to access attribute which was not in select:

$propertyType = $listings[0]->property_type; // returns `null`, but I need 
                                             // RuntimeException or ErrorException



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire