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
@AtiqSamtia
3 жыл бұрын
But the eloquent way is mostly better because it can run events & observers for any extra logic in the application and produce consistent data.
@kerolesmonsef4179
3 жыл бұрын
@@AtiqSamtia Offcourse but you will pay the price ( slowness )
@faradtech
10 ай бұрын
thank you for professional courses 💯💯
@l.mu.433
3 жыл бұрын
Man, You're the Best! Thanks a lot!!
@norbertocammayo2334
3 жыл бұрын
IMO you are one of the best laravel teacher. Keep it up.
@tlita93
3 жыл бұрын
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
@steveag8018
2 жыл бұрын
learnt smth new today
@kelvezu1585
3 жыл бұрын
Your daily contents are awesome.
@Shez-dc3fn
3 жыл бұрын
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..
@TsA1ex
3 жыл бұрын
Why you getting all() huge data, if use only 'id'. Try User::pluck('id') instead of User::all()
@LaravelDaily
3 жыл бұрын
Yes, you're right, but I tested it, and in my case, the impact wasn't big, only 0.05s.
@legato0
3 жыл бұрын
Useful tip. With extended tables, it will matter.
@lucianohanna1009
2 жыл бұрын
@@LaravelDaily What about RAM?
@msdeav
2 жыл бұрын
thank you...
@Pavelbrov
11 ай бұрын
5:09 - shouldn't we check in books is it confirmed or not as it was in original code on 4:56?
@syracuse4612
Жыл бұрын
it's really cool
@usherkadio3861
3 жыл бұрын
Very helpful like always ...thanks a lot
@fcorsair
3 жыл бұрын
Grear video! I wonder if using Builder instead of eloquent world improve seeding performance more... could it be a good solution?
@PovilasKorop
3 жыл бұрын
Yes, you are right, should be a bit faster.
@TundeAwopegba
3 жыл бұрын
Can you check for the memory consumed as well
@GergelyCsermely
3 жыл бұрын
Very good, thanks
@codewithtee
3 жыл бұрын
Very helpful, Thank you very much 🙂
@paulfontaine7819
3 жыл бұрын
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?
@LaravelDaily
3 жыл бұрын
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.
@paulfontaine7819
3 жыл бұрын
@@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();
@bestsolution794
3 жыл бұрын
Thank you . Can you please make 1 to 1 chat system or support system
@LaravelDaily
3 жыл бұрын
Here's a good article about it: modestasv.com/chat-with-laravel-pusher-and-socket-io-at-your-command/
@AtiqSamtia
3 жыл бұрын
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.
@LaravelDaily
3 жыл бұрын
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.
@alex_nita
3 жыл бұрын
Stupid question - what theme are you using for PHPStorm?
@bumblebity2902
3 жыл бұрын
Material dark maybe he used.
@Minepuffik
3 жыл бұрын
@@bumblebity2902 Yes it is Material Darker,
@Remls
3 жыл бұрын
Is it possible to see the GenresTableSeeder class?
@LaravelDaily
3 жыл бұрын
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); } }
Пікірлер: 35