I study how some functions are implemented in laravel because I want to understand some methods and principles of software development.
I understand that when calling a static method, such as "App \ User :: find (1) or App \ User :: whereId (1)", it is done on an eloquent model that the abstract model class implements the magic __callStatic method like this:
public static function __callStatic($method, $parameters)
{
$instance = new static;
return call_user_func_array([$instance, $method], $parameters);
}
I also understand that this line is '$ instance = new static;' makes an instance of some eloquent model in which a static call was made, for example, App \ User.
, : "call_user_func_array ([$ instance, $method], $parameters);".
, , call_user_func_array() $(, find ($ parameters)) eloquent (, App\user).
, , , . , "blah()":
App\User::blah();
"BadMethodCallException " undefined Illuminate\Database\Query\Builder:: fisd() '".
"Builder" ?
"BadMethodCallException ' undefined Illuminate\Database\Eloquent\Model:: fisd()'" "?
, Builder.