Eloquent where(): 6 'Tricks' You May Not Know

preview_player
Показать описание
Over the years, I've seen a lot of less-known usages of where() in Eloquent and Query Builder, let me show you a few of them.

Links mentioned in the video:

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

Thanks for the tips. One tends to do the 'old stuff' instead of enhancing your code. The tips are very helpful.

fanievdm
Автор

Such valuable information/reminders, thank you (again) Sir! 🙏

chlouis-girardot
Автор

i like whereAll, whereAny ... very handy

maxzak
Автор

One thing I cannot stress enough is orWhere with scopes or relations. Always use a callback for your orWhere statements. $author->posts()->where('foo', 'bar') will give you all posts belonging to the author where foo is 'bar', but $author->posts()->where('foo', 'bar')->orWhere('abc', 'xyz') will no longer have abc = 'xyz' scoped to the $author. Same goes with scopes. $builder->where('created_at', '<', now()->subYears(1))->orWhere('views', '>', 500); will probalby also not yield what you were expecting.

SebastianMares
Автор

Please what do you use to make quick printing like this?

fredchess
Автор

I didn't get the info about created_at won't work if there is a index on it, and would work then index is created with date ?? Could you please make a video on it ? Such conditions are commonly used throughout projects, but i guess many are unaware, including me.

NitishKumarPatra
Автор

would you please explain why the word(data) is put in page.jsx when using inertia ? example : to loop : i saw this and i don't know why . ( in working laravel with react inertia) i saw that .

BBBBBB
Автор

what i always tell people "read the docs". I get it if you come from other frameworks it's a pain

SXsoft