IMO you are one of the best laravel teacher. Keep it up.
@tlita934 жыл бұрын
Very interesting topic - seeders. I had an issue where I needed to seed content of about 30k text files to DB, which are just over text field limit and have to be mediumtext fields. It takes a solid amount of time, about a couple of minutes. I think it's due to using PHP's file_get_conent to read the file and write it's text to a field. Tho I'm not aware it can be done differently. Really great video sir. Your choice of topics always amazes me with uniqueness and usefulness, compared to a lot bigger channels, objectively speaking. Cheers
@kelvezu15854 жыл бұрын
Your daily contents are awesome.
@kerolesmonsef41794 жыл бұрын
Also there is a faster way . To store the seeder data as a bulk of records instead of singular . By using query builder instead of eloquent
@AtiqSamtia4 жыл бұрын
But the eloquent way is mostly better because it can run events & observers for any extra logic in the application and produce consistent data.
@kerolesmonsef41794 жыл бұрын
@@AtiqSamtia Offcourse but you will pay the price ( slowness )
@steveag80182 жыл бұрын
learnt smth new today
@l.mu.4334 жыл бұрын
Man, You're the Best! Thanks a lot!!
@Shez-dc3fn4 жыл бұрын
one thing to note is that you dont have to remove the user/book id from review factory even if we use your way. because laravel will use your way and ignore user/book id in review fact. reason is that maybe somewhere else (i.e. in tests) u might want to create a review row with random book/user..
@usherkadio38614 жыл бұрын
Very helpful like always ...thanks a lot
@msdeav2 жыл бұрын
thank you...
@codewithtee4 жыл бұрын
Very helpful, Thank you very much 🙂
@Pavelbrov Жыл бұрын
5:09 - shouldn't we check in books is it confirmed or not as it was in original code on 4:56?
@GergelyCsermely4 жыл бұрын
Very good, thanks
@fcorsair4 жыл бұрын
Grear video! I wonder if using Builder instead of eloquent world improve seeding performance more... could it be a good solution?
@PovilasKorop4 жыл бұрын
Yes, you are right, should be a bit faster.
@syracuse4612 Жыл бұрын
it's really cool
@TundeAwopegba4 жыл бұрын
Can you check for the memory consumed as well
@paulfontaine78194 жыл бұрын
In my experience, using SQLite, when inserting many records, performance can be significantly improved by wrapping (chunks of) inserts or updates in a DB transaction. Do seeders do that for you?
@LaravelDaily4 жыл бұрын
In this example, I haven't implemented transactions and DB facade instead of Eloquent models, that may also speed up a bit, but not by much, I think.
@paulfontaine78194 жыл бұрын
@@LaravelDaily just two statements around the rest for me provides sometimes 80% performance gain DB::beginTransaction(); // normal eloquent stuff with many small database writes DB::commit();
@TsA1ex4 жыл бұрын
Why you getting all() huge data, if use only 'id'. Try User::pluck('id') instead of User::all()
@LaravelDaily4 жыл бұрын
Yes, you're right, but I tested it, and in my case, the impact wasn't big, only 0.05s.
@legato04 жыл бұрын
Useful tip. With extended tables, it will matter.
@lucianohanna10092 жыл бұрын
@@LaravelDaily What about RAM?
@bestsolution7944 жыл бұрын
Thank you . Can you please make 1 to 1 chat system or support system
@LaravelDaily4 жыл бұрын
Here's a good article about it: modestasv.com/chat-with-laravel-pusher-and-socket-io-at-your-command/
@Remls4 жыл бұрын
Is it possible to see the GenresTableSeeder class?
@LaravelDaily4 жыл бұрын
Here's the shortened version: class GenresTableSeeder extends Seeder { public function run() { $genres = [ [ 'name' => 'Classic', 'description' => 'Fiction that has become part of an accepted literary canon, widely taught in schools', ], [ 'name' => 'Crime/detective', 'description' => 'Fiction about a crime, how the criminal gets caught and serves time, and the repercussions of the crime', ], [ 'name' => 'Epic', 'description' => 'A genre of narrative poetry in a time before history about extraordinary feats that involve religious underpinnings and themes.', ], // ... More genres ]; Genre::insert($genres); } }
@alex_nita4 жыл бұрын
Stupid question - what theme are you using for PHPStorm?
@bumblebity29024 жыл бұрын
Material dark maybe he used.
@Minepuffik4 жыл бұрын
@@bumblebity2902 Yes it is Material Darker,
@AtiqSamtia4 жыл бұрын
What if we don't load all users or genres when we know there would be exactly 100 records and simply use 1 to 100 random int for user_id. It'll save a lot of memory usage & processing. Also, seeders are run mostly on a fresh migrated database and very controlled environment possibility of that record not existing is very low.
@LaravelDaily4 жыл бұрын
Yes it would work based on those assumptions. But you never know who would work with your code in the future and whether they would assume the same things.