dimanche 18 novembre 2018

use of returning $this inside a method

I am using Laravel and eclipse as my IDE. I am using the laravel-ide-helper package for autocompletion.

I am calling a method from an eloquent model object. When I type in

User::where

eclipse provided me with the following:

where($column, $operator, $value, $boolean) : $this

which means the function "where" returns

$this

Now, I don't really know what $this means because as I understand it "where" should return a query builder instance. As far as I know, $this means the object caller of the method (in this context, the User model itself). But it clearly does not return the model. I suspect that I do not understand what $this means in this context.

What am I missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire