Eloquent One to Many Relationship | Laravel For Beginners | Learn Laravel

  Рет қаралды 42,606

Code With Dary

Code With Dary

Күн бұрын

Пікірлер: 65
@codewithdary
@codewithdary 3 жыл бұрын
LETS CONNECT THROUGH INSTAGRAM. www.Instagram.com/codewithdary
@FririkurEllefsen
@FririkurEllefsen 11 ай бұрын
Thanks for the tip about using the ForElse loop and "empty". I will rewrite some of my code and use those instead of numerous IF's
@codewithdary
@codewithdary 11 ай бұрын
Yes, it helps a lot!
@OurModernWorld
@OurModernWorld 2 жыл бұрын
i think that you are the best tutor ever, i just love your content, your way of explaining stuff is the best, with all do respect to all other tutorial creators.✌
@codewithdary
@codewithdary 2 жыл бұрын
Thank you so much John, comments like these make my day man
@OurModernWorld
@OurModernWorld 2 жыл бұрын
@@codewithdary cheers
@Ahabib2009
@Ahabib2009 2 жыл бұрын
Great Dary. Really appreciate
@codewithdary
@codewithdary 2 жыл бұрын
Glad you liked it Ahabib!
@sirbangalot569
@sirbangalot569 3 жыл бұрын
It's funny how I tried looking up adding foreign keys online and would always get an error...them booom💥 I do your tutorial and it works. Good work man, can't thank you enough
@codewithdary
@codewithdary 3 жыл бұрын
Always good to read that! Thank you for your kind words man!
@amiralipishdadi
@amiralipishdadi Жыл бұрын
thank you dary 😍 very good
@codewithdary
@codewithdary Жыл бұрын
You're welcome 😊
@william254
@william254 3 жыл бұрын
Great video as always Dary. Really appreciate
@codewithdary
@codewithdary 3 жыл бұрын
Thanks again!
@agafonovas
@agafonovas Жыл бұрын
Love your videos man 😮
@codewithdary
@codewithdary Жыл бұрын
Thank you
@lancespurgeon
@lancespurgeon 2 жыл бұрын
So much easier to understand, thanks. To build on your example of cars and car_model how would you automatically insert default 'name' with lastid create from cars table?
@fabiolisboa2156
@fabiolisboa2156 3 жыл бұрын
an excelente tutorial bro you illuminated my mind thank you so much
@kemal6039
@kemal6039 2 жыл бұрын
If you're having "Foreign key constraint is incorrectly formed" error, do these : 1 - On the migration file, change the type of your foreign key to unsignedBigInteger from unsignedInteger 2 - Make sure the table that foreign key belongs, is being migrated before the table(s) with foreign key. You can accomplish this by renaming its migration file, for example change the "2022_" in the start of the name to "2001_"
@codewithdary
@codewithdary 2 жыл бұрын
Thank you for sharing Kemal
@peteririogbe3444
@peteririogbe3444 3 жыл бұрын
Hello Dary. Thank you for your great tutorial. I enjoy it. Pls can you make a blog that has different categories. I need it
@codewithdary
@codewithdary 3 жыл бұрын
That's very interesting, I'll think about it :) I do got a complete tutorial on how to create a blog if you are interested.
@peteririogbe3444
@peteririogbe3444 3 жыл бұрын
@@codewithdary I have already downloaded it. I need more excellent tutorials from you. You are making my day so excited
@codewithdary
@codewithdary 3 жыл бұрын
Thank you so much Peter, you made my day with your comment! :)
@daffahanz1540
@daffahanz1540 3 жыл бұрын
Is the 'carModels' in '$car->carModels' a relationship function residing in the Car.php model?
@codewithdary
@codewithdary 3 жыл бұрын
Yes!
@chukwuebukaohaji5285
@chukwuebukaohaji5285 2 жыл бұрын
Hello Dary, nice video. I followed everything you did word for word (though different names etc) but I keep getting an error "Invalid argument supplied for foreach()". Please help out..
@tech-trials
@tech-trials 3 жыл бұрын
At the end of this video i used '{{ $model->model_name }}' and it worked for me dunno if thats cuz i used a separate migration for carModels instead of adding it into the cars migration
@codewithdary
@codewithdary 3 жыл бұрын
You can’t access arrays with the access operator [->]. It only applies to objects. But you can use the brackets to access an array. It just depends on how you pull out data from your database. If you var_dump your array, you can see what if it's an array/object/collection
@randomyuber5012
@randomyuber5012 3 жыл бұрын
Hey, lets say we wanna insert to the carModel table, do we have to create the controller for it aswell? Or is there another laravel magic to make this easier? Great tutorial btw!
@codewithdary
@codewithdary 3 жыл бұрын
Depends on what you want to do with the carModel, but in most cases nope.
@shafiu283
@shafiu283 3 жыл бұрын
I really like coding with Dary
@codewithdary
@codewithdary 3 жыл бұрын
Thank you Shafiu!
@Ramziddin_Rustamovv
@Ramziddin_Rustamovv 2 жыл бұрын
Hi bro , i have queation about this topic , now you insert all data manualy , if I except them from user , how can i insert them automatically in the controller . For example post's comment should only be equalto post which is blongs to when user commeted it , it should post automatically in comments table in the column of post_id .... Please answer .....
@mariuszdabrowski307
@mariuszdabrowski307 3 жыл бұрын
what if I want to create a new car model with the form. I have to get car_id from somewhere. my idea is to create a private variable in the controller. I set its value in the store (id) method but if I check its value in another method I wrote storeModel (). then its value is null. help please
@codewithdary
@codewithdary 3 жыл бұрын
One way of inserting related table is using relations as: $user = User::create($user_inputs); $xyz = $user->xyz()->create($xyz_inputs); It will automatically fills the user_id in the xyz table.
@mariuszdabrowski307
@mariuszdabrowski307 3 жыл бұрын
@@codewithdary in this way i must every time create new user when i want create xyz?
@JohnSmith-zl8rz
@JohnSmith-zl8rz 4 жыл бұрын
what's the goal to "protected" the table and the "primary key"?
@codewithdary
@codewithdary 4 жыл бұрын
the property or method can be accessed within the class and by classes derived from that class
@mamaddodol3528
@mamaddodol3528 3 жыл бұрын
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'car_models.blueprint_id' in 'where clause' (SQL: select * from `car_models` where `car_models`.`blueprint_id` = 5 and `car_models`.`blueprint_id` is not null) (View: C:\xampp\htdocs\final esources\views\cars\show.blade.php) the blueprint is the car model
@santhoshkumar-sf4bc
@santhoshkumar-sf4bc 3 жыл бұрын
Hi.., how to add column to table by migration without loss of data???
@codewithdary
@codewithdary 3 жыл бұрын
Read through this link (Scroll down a bit): devdojo.com/bobbyiliev/how-to-add-a-new-column-to-an-existing-table-in-a-laravel-migration
@alexpmh
@alexpmh 4 жыл бұрын
Hello! You described one to many relationship, so why the title is 'many to many'?
@codewithdary
@codewithdary 4 жыл бұрын
Oh hell, you are completely right. Changed it! My bad :)
@rajabhishek2936
@rajabhishek2936 4 жыл бұрын
Nice video
@codewithdary
@codewithdary 4 жыл бұрын
Very nice
@shawyarshah231
@shawyarshah231 3 жыл бұрын
Hi Dary thanks for the amazing videos about laravel. I have been facing something I don't know how to write the query in Laravel for it. I have two tables (users & user likes) users has two columns( id, name ) and user_likes has two columns ( user_id, liked_user), how can return all the users in users table except those users that the user has already liked them in Laravel? Please! for example: user 1in users table, liked user number 2 & 4. he can see all the users except user 2 & user 4. and so on for the other users. Please help
@b1olenyleny449
@b1olenyleny449 4 жыл бұрын
Hello, nice video, i wanted to ask you, if you could make a video how to synchronize data from checkboxes to database (i have issue when i want to insert an array of values into database from checkboxes, i want to automatically delete the unchecked checkboxes values from database) i was trying to search for it but couldnt find any solution, thank you for reading this.
@codewithdary
@codewithdary 4 жыл бұрын
Thanks for the idea!
@carlfranz6805
@carlfranz6805 2 жыл бұрын
Um. How do we get to the 'show' function? I keep getting a 404 not found. [edit] Never mind, fixed it, although I didn't figured it out (this is, I've no idea how I fixed it). I'm getting better at debugging this mess, I guess.
@codewithdary
@codewithdary 2 жыл бұрын
Keep working on it, debugging is such an important topic when it comes to coding!
@Enol_ww
@Enol_ww 3 жыл бұрын
Hey guys ! I have a question about the tables, basiclly I have a table let's say its about countries.... to insert the name of the country and population, and i also have a table that has more detail about that specific country (president,size). Here is the problem, i made a form to insert the president name and the size in the table with the details, but the foreign key here is the id of the first table...how can i make tell the form or to the controller that i dont want to let anyone to insert the id, and also to let laravel know that the id of the countri is in the url and i dont have to insert it i hope you guys understend, also... sorry for my bad english.
@aldrinedeguzman7652
@aldrinedeguzman7652 4 жыл бұрын
Dude how to show only one model name?
@codewithdary
@codewithdary 4 жыл бұрын
Do you mean the one to one relationship?
@aldrinedeguzman7652
@aldrinedeguzman7652 4 жыл бұрын
@@codewithdary in your video you show a1 a3 a5, how to make only one will show?
@Borma425
@Borma425 3 жыл бұрын
what about many to many ?
@brenol2177
@brenol2177 3 жыл бұрын
The most important part the guy didn't do, that is the insertions.
@codewithdary
@codewithdary 3 жыл бұрын
That guy has a name (me) and what do you mean insertions?
@brenol2177
@brenol2177 3 жыл бұрын
@@codewithdary Sorry didn't mean to offend. I mean the part about how to use laravel to insert the data with relations instead of adding it manually with mysql.
@codewithdary
@codewithdary 3 жыл бұрын
Oh no I'm sorry haha I like to joke around here, sometimes it sounds a bit serious! Ah yeah. That's also a part of the one to many relationship, you are right! :)
@brenol2177
@brenol2177 3 жыл бұрын
@@codewithdary thanks for the response :]
@codewithdary
@codewithdary 3 жыл бұрын
@Breno L no worries buddy :)
Introduction To Eloquent | Laravel For Beginners | Learn Laravel
45:20
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Laravel Roles and Permissions: All CORE Things You Need To Know
16:32
Laravel Daily
Рет қаралды 230 М.
Eloquent Polymorphic Relations: Properly Explained
9:56
Laravel Daily
Рет қаралды 42 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 172 М.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 146 М.
Laravel Eloquent | Many to many relationship from zero to hero .
14:04
Golang: The Last Interface Explanation You'll Ever Need
17:58
Flo Woelki
Рет қаралды 31 М.
Exceptions in Laravel: Why/How to Use and Create Your Own
12:18
Laravel Daily
Рет қаралды 89 М.