The are the same. whereSlug is a shorthand for where('slug', 'some-slug'). whereSlug is using where under the hood.
Jun 5, 2024
4
Level 4
Different where syntax?
I am aware you can perform a where via:
Post::where('slug', 'some-slug')->first();
But I have also seen:
Post::whereSlug('some-slug')->first();
There is no custom scope defined on the post model either.
Which one should be used, and why?
Please or to participate in this conversation.