How to find out where a particular method is determined? Let's say in laravel I have this:
$this->_price = $this->product()->first()->price;
the class is Item extends Entity
, but if I would check the Entity class it extends something else and that something else extends something more. The issue is that I can not see where this product()
method is determined and I can not find it by using my IDE. How to debug such cases where you don't know from where something comes up?
product() is a method that should define the relation - it is a method you need to add to your model.
If a method does not exist, PHP first look for it in parent model, and if not found, Eloquent logic looks for the method in the Eloquent builder, and if not found, Eloquent builder looks for it in a query builder. At some point you are also able to register extensions to the builder that can add some methods. So in general, with Eloquent, it's quite hard to identify where the method exists :)
But, as stated above, in this case this method should be defined by you.