No video

Eloquent Relationships in Laravel - All you need to know!

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

coder awesome

coder awesome

Күн бұрын

Пікірлер: 130
@tomiwaoluwole1818
@tomiwaoluwole1818 2 жыл бұрын
This is the best video I have watched in my entire life up till now. Today I understand relationship and can even teach people. Thanks man.
@coderawesome
@coderawesome Жыл бұрын
Thanks for your valuable feedback!
@mubafaw
@mubafaw 4 жыл бұрын
I appreciate your clarity and simplicity. The best!! Thanks Sir :)
@coderawesome
@coderawesome 4 жыл бұрын
Glad it was helpful!
@thesafaripictures3453
@thesafaripictures3453 3 жыл бұрын
The greatest tutorial on eloquent on the web. Thank you sir.
@coderawesome
@coderawesome 3 жыл бұрын
You're very welcome!
@mxoh8325
@mxoh8325 2 жыл бұрын
finally, someone made example of relationships. I have been struggling for many years thank you so much for this.
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@emileoosthuizen596
@emileoosthuizen596 Жыл бұрын
Thank you for this incredible video!
@coderawesome
@coderawesome Жыл бұрын
Glad you enjoyed it!
@Benjamin-vx2ot
@Benjamin-vx2ot 2 жыл бұрын
this was by far the best video for this topic! thank you!
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@gajen4evr
@gajen4evr 2 жыл бұрын
Good explanation brother..!
@coderawesome
@coderawesome Жыл бұрын
Glad you liked it
@firedragon1976eb
@firedragon1976eb Жыл бұрын
This is such a great explanation, thank you.
@coderawesome
@coderawesome Жыл бұрын
You're very welcome!
@83shahzada
@83shahzada 3 жыл бұрын
Awesome Tutorial, Complicated Scenario - Explained So Simple and Clear
@coderawesome
@coderawesome 3 жыл бұрын
Glad it was helpful! Thanks a lot for your feedback!
@ahmadbilal168
@ahmadbilal168 3 жыл бұрын
it is so much useful for beginners.thanks for this
@coderawesome
@coderawesome 3 жыл бұрын
Glad it was helpful! Thanks!
@eidm5715
@eidm5715 4 жыл бұрын
Thank you for all relevant information. I learned one important concept related to easy loading in this tutorial
@coderawesome
@coderawesome 4 жыл бұрын
Glad it was helpful!
@SaddamAnsari-df7ez
@SaddamAnsari-df7ez 2 жыл бұрын
thank you very very much sir ji
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@cloudydandy
@cloudydandy 3 жыл бұрын
Thank you for your effort. I watched in Speed:1.25.
@coderawesome
@coderawesome 3 жыл бұрын
You're most welcome!
@jakye
@jakye Жыл бұрын
Awesome tutorial! At 13:55 I would consider renaming the pivot table from "user_role" to "role_user" to use all of the eloquent features, because the models need to be alphabetically ordered.
@coderawesome
@coderawesome Жыл бұрын
Yes, that's no issue! Thanks!
@azlanuza1330
@azlanuza1330 2 жыл бұрын
It helped me learn a lot in Laravel eloquent. Good tutorial indeed.
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@rubanjacob2111
@rubanjacob2111 4 жыл бұрын
Very Nice Explanation
@coderawesome
@coderawesome 4 жыл бұрын
Thanks a lot!
@dasuneranda
@dasuneranda 3 жыл бұрын
Thanks bro. Great Explanation!
@coderawesome
@coderawesome 3 жыл бұрын
Glad it was helpful! You're most welcome!
@simoneverett12
@simoneverett12 3 жыл бұрын
Top job, Your video really helped to the point! BANG ON!! Keep up the amazing work!!
@coderawesome
@coderawesome 3 жыл бұрын
Thanks a lot for your feedback!
@rjchhetri2370
@rjchhetri2370 3 жыл бұрын
I'm confused with the pivot table. Why dont we make hasMany relation on User model so it links to the Role Model and in Role Model we define belongsTo relation for User
@vaibhavsrivastava4099
@vaibhavsrivastava4099 3 жыл бұрын
simple and very clear..
@coderawesome
@coderawesome 3 жыл бұрын
Thanks a lot for your feedback!
@shazirshafeeque6240
@shazirshafeeque6240 3 жыл бұрын
Good explanation brother. You nailed it. Superb :)
@coderawesome
@coderawesome 3 жыл бұрын
Thanks bro! Glad you liked it!
@alexneo9388
@alexneo9388 3 жыл бұрын
Awesome Tutorial, Thanks a lot...
@coderawesome
@coderawesome 3 жыл бұрын
You're most welcome!
@Shiv-vb1re
@Shiv-vb1re 2 жыл бұрын
Thanks
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@tuanphamvan655
@tuanphamvan655 2 жыл бұрын
very good
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@ehSamurai3483
@ehSamurai3483 3 жыл бұрын
$this->belongsToMany("App\Role") means that user belong to many roles, isn't it same as hasMany("App\Roles"). this also means that user has many roles right,
@coderawesome
@coderawesome 3 жыл бұрын
Nope. They're different. belongsToMany is a Many to Many relationship (A product can be belongs to many categories. And each category has many products), while hasMany refers to a One to Many relationship (A product can have many images, But one image only belongs to a one product.).
@rahi4030
@rahi4030 3 жыл бұрын
you saved me sir thank you so much
@coderawesome
@coderawesome 3 жыл бұрын
You are most welcome
@ashadulmridha4265
@ashadulmridha4265 3 жыл бұрын
Thanks You
@coderawesome
@coderawesome 3 жыл бұрын
You're most welcome!
@haykhayrapetyan1489
@haykhayrapetyan1489 3 жыл бұрын
thanks bro, I found what I need
@coderawesome
@coderawesome 3 жыл бұрын
I'm glad that you enjoyed the tutorial. Thanks a lot for you feedback!
@thecalmcompass1
@thecalmcompass1 4 жыл бұрын
Thank you. I will practise it.
@coderawesome
@coderawesome 3 жыл бұрын
You can do it! Thanks a lot for your feedback!
@muhammadshafeerp3435
@muhammadshafeerp3435 3 жыл бұрын
very useful video thanks
@coderawesome
@coderawesome 3 жыл бұрын
Glad it was helpful! Thanks a lot!
@TrikNgonlen
@TrikNgonlen 3 жыл бұрын
I love it...that's awesome...
@coderawesome
@coderawesome 7 ай бұрын
Glad you liked it! You're most welcome!
@auroraapps1853
@auroraapps1853 2 жыл бұрын
Great explanation!, please tell me what extension you are using, its mentioning prefix before string like (foreign, relation, etc ) ? please tell me
@coderawesome
@coderawesome 7 ай бұрын
Hi, I'm sorry I am not sure what you'r asking about ? What extension exactly ?
@_bihim
@_bihim 3 жыл бұрын
Love you
@coderawesome
@coderawesome 3 жыл бұрын
Love you too brother!
@ehSamurai3483
@ehSamurai3483 3 жыл бұрын
We can do like this User::find(1)->getaddressRelation; Right? So why use with()->get()?
@coderawesome
@coderawesome 7 ай бұрын
That function came in a later version of Laravel I guess. This method works for older versions.
@KhaledGhallabPro
@KhaledGhallabPro 3 жыл бұрын
Very nice Thaks..
@coderawesome
@coderawesome 3 жыл бұрын
Thanks a lot for the feedback. Much appreciated!
@MatejSK1
@MatejSK1 3 жыл бұрын
Hello please can you tell for example how you can get all comments from 1 user for one post ? because its very hard for me to get the certain values from object which especially if i want to do it in the table . I am making ordering system for cars and I got like 5 tables and i want to display all the datas from each to one big table, so i have to do it in foreach cycle.
@coderawesome
@coderawesome 3 жыл бұрын
It's fairly easy. You have to call a relationship within a relationship. that's it. Define getUserRelation(); relationship on Post model. And getCommentsRelation(); on User model. Then finally call it like this. Post::with('getUserRelation.getCommentsRelation')->find($id); That's it.
@michaelerwin8744
@michaelerwin8744 2 жыл бұрын
6:06 AFAIK it's die and dump but sometimes programmers and debug and die in the office.
@coderawesome
@coderawesome 2 жыл бұрын
Yeah it's been confusing for a while for me too :D
@sergey_gabrielyan1001
@sergey_gabrielyan1001 4 жыл бұрын
Thank you very much👍🏻
@coderawesome
@coderawesome 4 жыл бұрын
You are welcome!
@7421Roman
@7421Roman 3 жыл бұрын
he was not wrong with that title
@coderawesome
@coderawesome 3 жыл бұрын
Thanks! something wrong with the title ?
@7421Roman
@7421Roman 3 жыл бұрын
@@coderawesome its perfect
@MohsinKhan-sk5lh
@MohsinKhan-sk5lh 3 жыл бұрын
great
@coderawesome
@coderawesome 3 жыл бұрын
thanks brother!
@victorfernandogilcalderon6242
@victorfernandogilcalderon6242 3 жыл бұрын
Excelente explicaciones. "Nos has salvado estamos agradecidos" By Toy Story
@coderawesome
@coderawesome 3 жыл бұрын
gracias por su respuesta. Me animó. 😍
@melchiasystemlord8608
@melchiasystemlord8608 3 жыл бұрын
is it possible to consume 1 user with many addresses all at once in 1 form submit using eloquent?
@coderawesome
@coderawesome 3 жыл бұрын
Yeah, you can pass an array of addresses like this Model::insert($data); Here, $data is a multi-dimensional array of addresses.
@nishanthanr605
@nishanthanr605 3 жыл бұрын
Which software you use for screen recording.
@coderawesome
@coderawesome 3 жыл бұрын
It's Camtasia
@yogeshsaini254
@yogeshsaini254 3 жыл бұрын
Thanks sir😍
@coderawesome
@coderawesome 3 жыл бұрын
Most welcome!
@rohankumar1475
@rohankumar1475 4 жыл бұрын
hello, i want to how this query write in laravel ORM(without where and with where) "select student.name, cities.city from students INNER JOIN cities on student.city_id=cities.id" where students.id=1 i have student table with city_id and other columns and cities table with id,city
@coderawesome
@coderawesome 3 жыл бұрын
You can achieve that with Sequelize relations easily. May be I'll do a separate video about relations later.
@2cents2go
@2cents2go 4 жыл бұрын
Great and easy to understand concepts. The only thing is that it's a little hard to see your screen since sometimes other devs and I view this on a phone.
@coderawesome
@coderawesome 4 жыл бұрын
Yeah I agree with you. Sorry about that. Thanks for your feedback!
@babathombare2693
@babathombare2693 Жыл бұрын
Content does not fit into window. Not visible neatly.
@coderawesome
@coderawesome 7 ай бұрын
Totally agreed. Really sorry about that.
@thielicious2156
@thielicious2156 2 жыл бұрын
4:02 What is this line in v9.x? Looks quite different
@coderawesome
@coderawesome 7 ай бұрын
This video is little bit outdated. Please refer the official Laravel docs for the updated sysntax.
@alakshminagasri3011
@alakshminagasri3011 3 жыл бұрын
Can you tell me the difference between joins and relations, and when we have to use joins and relations
@coderawesome
@coderawesome 3 жыл бұрын
You JOIN tables to generate RELATIONSHIPS. When you use raw SQL, you have to manually join tables using queries to get the related data in other tables. But with an ORM which automatically writes SQL for us, all you have to do is define the relationship you wanna generate and ORM will join related tables and will output the data with relationships.
@nizz4m
@nizz4m 2 жыл бұрын
Will eloquent relationship works without table migrations ? . Btw thanks for great content !
@coderawesome
@coderawesome 7 ай бұрын
Yes it works! Just make the tables with correct foreign keys.
@nurrashiqahabdulwahid6871
@nurrashiqahabdulwahid6871 3 жыл бұрын
thank you for the tutorials sir. im your 267 subs. it helps me to understand better but i have a question, where does the data comes from? 6:55 . are they from database or you are using php artisan tinker? i really hope you can reply me, sir as im really new in laravel. thank you sir
@coderawesome
@coderawesome 3 жыл бұрын
Thanks a lot! Yes, I have put some sample data in a table for this demonstration.
@nurrashiqahabdulwahid6871
@nurrashiqahabdulwahid6871 3 жыл бұрын
@@coderawesome welcome sir. do you know how to fetch data from multiple table using these eloquent? ive been looking and searching everywhere and trying everything but nothing works sir. hope you can upload one soon. have a great day!
@coderawesome
@coderawesome 3 жыл бұрын
@@nurrashiqahabdulwahid6871 Sure. That's what these eloquent relationships are for. You can build relationships between tables and get data.
@nurrashiqahabdulwahid6871
@nurrashiqahabdulwahid6871 3 жыл бұрын
@@coderawesome I got confused to use the foreach loop in view.blade.php, it's keep getting an error there. looking forward to your videos sir 🙏
@alexlytle089
@alexlytle089 3 жыл бұрын
How about has many through and has one through relationship
@coderawesome
@coderawesome 3 жыл бұрын
That's not hard at all. I'm sorry that I haven't mention them in the video. Please follow this article (www.itsolutionstuff.com/post/laravel-has-many-through-eloquent-relationship-tutorialexample.html) it'll guide you with a practical example. I'll try to publish another video if I had the chance.
@harikareddy9166
@harikareddy9166 3 жыл бұрын
hi can u explain how to fetch multiple tables data in a single view page in laravel
@coderawesome
@coderawesome 3 жыл бұрын
That's simple. In the controller, get the data from certain tables using their respective modals. Then create an array and pass those data to certain keys. Then u can return that array to the view.
@omrai7743
@omrai7743 3 жыл бұрын
How can we get only selected record from belongs to table?
@coderawesome
@coderawesome 3 жыл бұрын
Can u be more specific ? There are many ways of doing. What exactly are u trying to do ?
@Lea-uu4yk
@Lea-uu4yk 2 жыл бұрын
what about recursive? the manager manage many staffs?
@coderawesome
@coderawesome 2 жыл бұрын
Is a single staff person managed by only one manager ? Then that's clearly a one to many relationship. Is a single manager is managed by multiple managers, then that's many to many.
@shubhamsahuSD
@shubhamsahuSD 2 жыл бұрын
Details about cascade delete please
@coderawesome
@coderawesome 7 ай бұрын
Cascading deletes are needed when a dependent/child entity can no longer be associated with its current principal/parent. This can happen because the principal/parent is deleted, or it can happen when the principal/parent still exists but the dependent/child is no longer associated with it.
@lyeell6989
@lyeell6989 3 жыл бұрын
Muchas gracias,
@coderawesome
@coderawesome 3 жыл бұрын
no hay de qué. Disculpas si mi español es malo 😇
@rajeshvuppala8083
@rajeshvuppala8083 3 жыл бұрын
Bro can u please share the extension that u used for getting suggestions in vscode
@coderawesome
@coderawesome 3 жыл бұрын
Actually that's PHPStorm. It's another IDE.
@rajeshvuppala8083
@rajeshvuppala8083 3 жыл бұрын
@@coderawesome ok thank you bro Php strom is free or paid IDE
@coderawesome
@coderawesome 3 жыл бұрын
@@rajeshvuppala8083 Unfortunately it's a paid IDE. But, if you're a student, you can request a free version with your student ID provided by the institution.
@hellwolf-media
@hellwolf-media 4 жыл бұрын
Excelente +10
@coderawesome
@coderawesome 4 жыл бұрын
Thanks a lot!
@danichurras
@danichurras 3 жыл бұрын
meow meow thanks
@coderawesome
@coderawesome 3 жыл бұрын
Thanks a lot for your feedback!
@plotpix941
@plotpix941 3 жыл бұрын
Please Zoom in your screen next time
@coderawesome
@coderawesome 3 жыл бұрын
Sure! My bad. I'm sorry for the difficulty to read. Later videos are much clear and zoomed in.
Laravel Eloquent Relationships: [1] One to One
17:33
Designated Coder
Рет қаралды 833
Eloquent Polymorphic Relations: Properly Explained
9:56
Laravel Daily
Рет қаралды 40 М.
天使救了路飞!#天使#小丑#路飞#家庭
00:35
家庭搞笑日记
Рет қаралды 85 МЛН
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 18 МЛН
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 21 МЛН
Lesson 10 Laravel Relationships in depth
29:21
Code With ERaufi
Рет қаралды 648
5 Laravel Relationship Tips That You Might Not Know About
8:21
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 139 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 59 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 145 М.
天使救了路飞!#天使#小丑#路飞#家庭
00:35
家庭搞笑日记
Рет қаралды 85 МЛН