Thanks Povilas for all the positive feedback. The Seeders were added to the migrations as I was uncertain on how to prevent them from being run multiple times while is on the dev server. I have since realised that I could just use php artisan db:seed --class=AllergenSeeder for current dev and leave it in the DatabaseSeeder class for new installations
Also, in all the seeds you could run firstOrCreate() or updateOrCreate() on all records, so if they exist, they wouldn't be created again when seeds are run for the second time, for whatever reason.
Quick performance tip: At 8:20 in line 47. It'd be best to take out the count() function from the for loop and put it in a variable. because every loop you are executing count() function again. It might not make sense In this situation because I assume ingredients aren't that many, but in other scenarios, it might help.
well in my opinion, i would use seeder in migrations only if i need data in table right from the start, for example i have "countries" table which doesn't change a lot and i have foreign keys from "addresses" table... other example is "product_states" table i have only new and used records (maybe client will add some more later)... but nicely done factories are a bit better solution for this example... other example is maybe if a client wants a slug and not id in urls, and i don't have "slug" column... so i would make a migration, create a "slug" column in it and right after foreach record fill the column, because i will definitively forget to run seeder on deployment
I believe that Laravel has a default validation rule for checking and validating a given password against the authenticated user's password. I don't see why would he create a custom rule for that.
Running seeders through migrations is the most correct approach. First of all, in the CD / CI migrations will be started and you will not need to create additional conditions to run when new seeders are created in the application. How you run new seeders on a working application? Manually? Second, you can rollback at any time and delete this data if anything goes wrong. By default, seeder mechanism does not provide such an option and creating ex. RemoveUsersSeeder is simply pointless.
Povilas, greetings! Could you give me an advice, please. When building an API on Laravel, what should i use for editing data on output. Eloquent Mutators or API Resources?
@@LaravelDaily Good, they are really good ways to learn. I have done those to juniors I meet at my client companies, they learn quickly and they actually adopt. Sort of the feeling you get when teaching something new to your kid and just being proud about him progressing lol
@@ward7576 Поставил laravel 8 на Open Server для локальной разработки и не могу найти мануал как правильно в 8й версии удалить сегмент "public" из url.
@@user-vs4sd6lw5e Сари в чем дело то. Как бы, папка бублик ваще не должна быть в урл. Я так понял, у тебя http:127.0.0.1:8000/public/mypage только открывает? Или как? Скинь урл.
3 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qyJ_yZuV5gY.html i have question about $recipe->ingriends()->attach()... does it checks in database if hat record exists? if no, what happens if i add custom ID to dropdown or checkbox.