The last one is like when you have a HTML select input, where you only need the "id" and the "title" rather than loading all of the rest of the data. Good video, cheers.
When a TV show has casts, crews, posters, backdrops, translations, trailers and seasons, seasons has translations and episodes, episodes has translations and a video file and video file has a progress you learn quick to do all these eager loadings on the database level, not to mention using the right indexes on the keys your relations uses. That saves 2 to 5 minutes and 500mb on the worst case scenario 😅
One more important thing, it's very easy to use model $with variable to eager load relationship. But in much cases this data isn't used for example in model index. In that cases you can see how the performance decrease, specially with polymorphic relationship. It's better to retrieve relationships only for show and edit methods, where they will be really used, but not always through the model $with.
Do you mind sharing those examples where PHP manipulation was seen more speedy than MySQL? Please share your experiences. Eager to learn more from you. Respect from Pakistan.
i like how you categorize your video with the related topic for example in this video you prefix title with "Eloquent Performance:" it will be so good when someone search for performance in channel 👏👏
Another way to explain $user->post->count() is that when we load a model either with relationship or not the returned data is a collection instance. And in the collection documentation we have ->count() method that counts data from the returned collection and not from databse.
Sir, I need to load 10 different kind from database news table based on their category which would be faste method 1:- $news_cat_1 = News::where('cat_id','1')->get(); $news_cat_2 = News::where('cat_id','2')->get(); . . . $news_cat_10 = News::where('cat_id','10')->get(); Method 2: $allNews = News::all(); $news_cat_1 = $allNews->where('cat_id','1')->get(); $news_cat_2 = $allNews->where('cat_id','2')->get(); . . . . $news_cat_10 = $allNews->where('cat_id','10')->get();
Great! I made the 3rd mistake too much when I made PDF reports that contained more than 10,000 records. Instead of creating a ReportResource with only the fields needed for the report, I used a Resource that returned all the fields in the table. For many records, it makes a total difference in the total size of json that the frontend needs to download from the backend.
For the last case, I have a similar problem. In my database, I have almost 13.000 records of users. I have to process them all to get stats of users by checking an attribute value (0, 1, 2, 3). Loading data from database is fast, but process them in the foreach takes 40s. And obviously only that attribute and ID are loaded. Is there a way to do that operation for minimum time?
Thank you sir for sharing it. I would like to know which front end framework do you suggest for a mid beginner of Laravel ? Live wire; vue, reactjs, jet-stream ,…..
How would you do an API to debug this? Please, it would be very interesting to attack this type of problem, basically because my stack in more than 200 projects is always Vue.js and Laravel API
I do filtering in PHP if whether the user can see an object is based on some permissions. For example, different users in a store have different payment methods available. I can't think of a simple way to filter that in the database. In PHP, you can use Collection::filter() to check if $user->can().
Great, I was always confuse to use relation with '( )' or without '( )', and also with eager loading, i have cleared the difference between that but can you please define more about eager loading and lazy loading and stuff like that, It would be really helpful. Thanks
You could use itsgoingd/clockwork. It has a similar feature to debugbar to add a footer with some request information, and in my opinion is a bit simpler than Telescope.
@LaravelDaily I liked your videos much. Rather I say, I am learning Laravel by watching your videos only. I have a doubt. At 1:30, 2:25 or 5:05 you are showing us DB queries count and all DB queries. How can I see it in my browser. Is there any specific software or chrome extension for it? Also, please share list of all extensions and softwares that you use while development.
hi sir i still not understand about ur relasi using withCount(posts) and u get data in index using $user->post_count , and ur relasi name is posts , do u can tell me about $user->post_count coz ur name relasi is posts not post_count . thanks
Hi sir Can u make a video on upload large CSV in db fast using queue I worked on it its working fine but due to my server limitation sometimes queue fails
@@LaravelDaily Thank you sir for reply. but actually my issue it is. I have make a Laravel 5.8 project In which many API are make for android APP. And one user find a bug his using our app and get some error. It shows the code of the .evn file. so how to secure .evn file to get any error.
Hi Povilas, nice video. Which is your current stack for php/laravel development locally? I am using docker locally, but your video it seems very faster.
@@LaravelDaily Tks for the answer. It looks very good. Docker became lazy because of the sync of files between container/local env even using :delegated
Excuse me, sir I have seen two methods in the Eloquent part are `fresh` and `refresh` BUT I do NOT know what is the benefit of these methods So, can you please explain more about these methods?
@@LaravelDaily I can NOT send the link because every time I send a link it deleted So, search for `Eloquent: Getting Started` in the docs then you'll find the `Refreshing Models` title
Good video thanks , can you please make a video on how to design a database digram I struggle a lot with it Please like this comment for him to see this
I have a full course: laraveldaily.teachable.com/p/how-to-structure-database-in-laravel Also, an old video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-RbKEYDtkAJI.html