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', '', 500); will probalby also not yield what you were expecting.
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.
would you please explain why the word(data) is put in page.jsx when using inertia ? example : to loop : projects.data.map(project).... i saw this and i don't know why . ( in working laravel with react inertia) i saw that .
Thanks for the tips. One tends to do the 'old stuff' instead of enhancing your code. The tips are very helpful.
Such valuable information/reminders, thank you (again) Sir! 🙏
Thanks for the detailed explanation..
Thanks for these useful tips
i like whereAll , whereAny ... very handy
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', '', 500); will probalby also not yield what you were expecting.
Thank you very much!
Please what do you use to make quick printing like this?
Tinkerwell
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.
I mean you need to create an index on DATE(created_at) and not created_at, not sure it needs a video
would you please explain why the word(data) is put in page.jsx when using inertia ? example : to loop : projects.data.map(project).... i saw this and i don't know why . ( in working laravel with react inertia) i saw that .
From what I remember, it's how Laravel API resources return the data by default. Read the docs of Eloquent API resources.
what i always tell people "read the docs". I get it if you come from other frameworks it's a pain