There is a little difference between whereId and find.
Eloquent Builder whereId
I just confirmed this exists and works... yet I can't find any documentation or even function definition anywhere in Laravel. How does this mythical method work?
@kalvinmizzi Those calls end up in the core builder. Eloquent does much of this magic thanks to PHP's magic __call and __callStatic methods.
User::whereId()->first();
That would first hit __callStatic magic method on the core model:
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Model.php#L2331-L2334
Which is forwarded to __call now that the model is instantiated:
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Model.php#L2311-L2322
It ends up giving a new Eloquent builder, but it will not match any given methods, thus forwards to the core query builder
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Builder.php#L1864
And then the core builder handles the magic once more
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Query/Builder.php#L3776-L3778
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Query/Builder.php#L1890-L1924
Please or to participate in this conversation.