I see this in a laravel tutorial :
Auth::user()->item;
where item is a function, inside models\User.php :
function item() { return $this->hasMany('Item', 'owner_id'); }
where Item is for models\Item.php
So why the parentheses is not needed when item function is called ? Like : Auth::user()->item();
If I put the parentheses, the browsers goes crazy and crash.
Also, if I rename Item.php to Item2.php, rename class Item to Item2, and I do hasMany('Item2', 'owner_id')
, it won't work. But why ? Where does 'Item' came from ?
Thanks,
Patrick
Auth::user()->item
? My preliminary conclusion is that somewhere needs the reference of the function. – Riles