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.
@@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
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?
Maybe use setAttributes function, if it is need to pass checkbox values.
3 роки тому
ua-cam.com/video/qyJ_yZuV5gY/v-deo.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.
@@ward7576 Поставил laravel 8 на Open Server для локальной разработки и не могу найти мануал как правильно в 8й версии удалить сегмент "public" из url.
@@user-vs4sd6lw5e Сари в чем дело то. Как бы, папка бублик ваще не должна быть в урл. Я так понял, у тебя http:127.0.0.1:8000/public/mypage только открывает? Или как? Скинь урл.
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.
Check doctrine approach. Seeders are overengineering :)
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.
At 9:11 you can add second condition inside Gate logic and use only one condition
true
Unless its on an older version of Laravel before it was a thing, there is a built in rule for the current password called "current_password".
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
wonderful review
Thanks sir you are great :) and a gem for laravel devs
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.
The CI/CD is my more recent reason for using the seeder in the migration.
That was awesome! 👍 So many thanks
Love this videos💙
How to use two arrays in a single foreach loop ?possible?
Can you make video about seo
Thanks, interesting!
I could actually try to send in something for code review, since I haven't gotten a CR from my more knowledgeable peers for like 2-3 solid years lol
I currently have a long queue of reviews already, so realistically only in September.
@@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
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?
API Resources: laravel.com/docs/8.x/eloquent-resources
New bad fast refactoring. At 8:03 you lost 'adults' and 'kids' values if checkbox not checked. Because there is request->has
Good catch, should have noticed that one. Need to be more careful in the future.
Maybe use setAttributes function, if it is need to pass checkbox values.
ua-cam.com/video/qyJ_yZuV5gY/v-deo.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.
I'm sorry, that my question is not actual for this video, but tell please, how currect in Laravel 8 remove "public" segment from url ?
Thank you.
say it in russian, I can re-translate so it's understandable much better.
Ты на хостинге чтоль используешь? И, если да, то на каком?
@@ward7576 Поставил laravel 8 на Open Server для локальной разработки и не могу найти мануал как правильно в 8й версии удалить сегмент "public" из url.
@@maxgoose4671 Пока поставил только на локальный вебсервер (Open Server)
@@user-vs4sd6lw5e Сари в чем дело то. Как бы, папка бублик ваще не должна быть в урл. Я так понял, у тебя http:127.0.0.1:8000/public/mypage только открывает? Или как?
Скинь урл.