I see this in the laravel lesson:
Auth::user()->item;
where item is a function, inside \ User.php models:
function item() { return $this->hasMany('Item', 'owner_id'); }
where Item for models \ Item.php
So why brackets are not needed when calling an element function? For example: Auth::user()->item(); If I put brackets, browsers go crazy and crash.
Also, if I rename Item.php to Item2.php, rename the Item class to Item2 and I do hasMany('Item2', 'owner_id') , this will not work. But why? Where did the element come from?
Thanks,
Patrick
source share