Laravel Pivot Tables: Simple to Advanced Many-to-Many

Laravel Pivot Tables: Simple to Advanced Many-to-Many

Laravel Daily

4 года назад

118,088 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Rejowan Ahmed
Rejowan Ahmed - 26.08.2023 01:47

I have a query here, why you put foreignPivotKey projects_id and relatedPivotKey users_id in the belongsToMany method? Shouldn’t it be, belongsToMany(User::class, 'user_id', 'id'),

Ответить
Иван Петров
Иван Петров - 02.07.2023 21:31

thanks, its a great help

Ответить
Ernesto Pareja
Ernesto Pareja - 17.06.2023 17:26

Thank you. Great as always

Ответить
dascorp
dascorp - 16.04.2023 23:12

@PovilasKorop How can we order the results by field in pivot model relation? using the video example by managers name - `$user->pivot->manager->name`

Ответить
Alvin Kariuki
Alvin Kariuki - 14.02.2023 22:45

You don't know how much I needed this 😂 thank you so much

Ответить
Jakov Pavlov
Jakov Pavlov - 09.02.2023 19:33

I tried this in Laravel 9 with three tables involved in the many to many relationship, Project / User / Role, and it worked!!! Thanks a lot

Ответить
Fahmi Ally
Fahmi Ally - 01.02.2023 09:52

Abit confusing

Ответить
essam Al_agamy
essam Al_agamy - 05.12.2022 13:29

Thank you very much for this information💙

Ответить
Marcelo
Marcelo - 28.11.2022 23:29

Thanks a lot !!!! You help so much... I not understand english very well, but I follow your videos and then help me so much... Thank you

Ответить
Akar Imdad
Akar Imdad - 18.11.2022 01:48

this video helped me so many times
Great video

Ответить
Chris De David
Chris De David - 14.11.2022 11:31

Hi, why did you only define the relationship one way?
Have a video showing many-to-many relationship defined both directions (from Users and Projects)?

Ответить
Fabian Gomez
Fabian Gomez - 25.10.2022 23:09

Thanks!!!

Ответить
dcxwms
dcxwms - 03.10.2022 23:20

Must say I'm watching a while and a i bought the stuff - this one is by far one of the best, there's very limited content out there on this topic that explains it like this so many thanks!

Ответить
Prashant redspark
Prashant redspark - 24.08.2022 11:42

This is working fine but I am not able to see pivot result in controller response(not in blade). How I can achieve? And is it working fine with API?

Ответить
Mai Tân
Mai Tân - 18.08.2022 16:48

Hi. Can I get one(latest) record with belongsToMany?

Ответить
Risang Baskoro
Risang Baskoro - 04.08.2022 15:58

Just realized that the manager() method in Invitation model can just have $this->users()->wherePivot($condition) logic.

Ответить
Chris
Chris - 02.08.2022 12:37

i feel like i can only understand eloquent relations by actually using them.

Ответить
Loïc Rutabana
Loïc Rutabana - 12.07.2022 19:14

I knew nothing about pivot before I came here. Now I know how much I don't know. Still confused. That is all

UPDATE: nvm I get it now

Ответить
yusuf öz
yusuf öz - 26.06.2022 20:16

you are the king. if you come to turkey i will buy you adana kebab.Thank you king:)

Ответить
Денис Самсонников
Денис Самсонников - 21.06.2022 12:47

awesome thank you!!

Ответить
Ken Johnson
Ken Johnson - 19.06.2022 20:44

This was incredibly useful, thank you! I was struggling to find a good detailed overview of how pivot tables work. The laravel documentation is not clear if you're not already familiar with them. I appreciate you!

Ответить
Rihulfa Akbar
Rihulfa Akbar - 12.06.2022 03:22

Hi, I'm having a hard time to relate 3 tables with eloquent. Product table, recie table and material table. How should I relate them if product has one recipe and within recipe has many materials?

Ответить
Chris Backhouse
Chris Backhouse - 29.05.2022 19:17

Ok, I thought I knew pivots, even complex ones, until I watched this. I always learn something from your videos. Truly inspirational! 👍

Ответить
PH Coder
PH Coder - 28.05.2022 14:40

hello how to join that manager_id using users table id to join pivot project_user?

Ответить
j o
j o - 26.05.2022 19:02

how come you don't show the ProjectFactory? I'm wondering how to write that out.

Ответить
Rober BurnDay
Rober BurnDay - 01.05.2022 17:26

Hi! I have a question: are there an massive attach or massive sync in laravel?

Ответить
Nadea Bocancea
Nadea Bocancea - 29.04.2022 19:38

Thank you for your work and extremely useful content!!!!

Ответить
rijal
rijal - 18.04.2022 05:35

thank you my error has been resolved now

Ответить
Benzaza Laid
Benzaza Laid - 15.04.2022 13:25

you explain very very very good , thank and God give you peace

Ответить
Ngebolang ria
Ngebolang ria - 22.03.2022 23:42

Thank you !!!!

Ответить
Kaylee Herrmann
Kaylee Herrmann - 10.03.2022 04:41

I liked this before I even watched it as I already knew your video would help me! Thanks for such consistent high-quality content.

Ответить
Matak
Matak - 07.03.2022 19:41

Hello Sir, How to signup account on your Laravel Daily site?
I see only login.

Ответить
Matak
Matak - 07.03.2022 19:26

Hello Sir, Can I know which tool are you using to view Database in your video?
Is it free or need to buy?

Ответить
silvester wali
silvester wali - 22.02.2022 15:53

it's save my day. thanks so much

Ответить
Quy Quyền Quý
Quy Quyền Quý - 21.01.2022 13:57

can I access manager() pivot model method from $project instance, i.e $project->pivot->manager?

Ответить
Nursema Günbay
Nursema Günbay - 18.01.2022 16:11

Billurlarına sağlık be adam.

Ответить
Josiah T Mahachi
Josiah T Mahachi - 12.01.2022 14:34

Thank you for this video. I was wondering how to set a value for one (or more) of the columns in the pivot table while attaching. For example, when attaching a user to a project and set is_admin to 1 at the same time.

Ответить
Abdulrahman Alsefi
Abdulrahman Alsefi - 02.01.2022 16:23

What if every project has multiple managers

Ответить
Masoud Saeedi
Masoud Saeedi - 25.12.2021 09:35

awesome

Ответить
Hardik Lakhalani
Hardik Lakhalani - 16.12.2021 10:38

There are auto labels inside brackets in migration file. "table, column etc.." What's that feature called? I'd like the same working in VSCode.

Ответить
Gabriel P. Zonatto
Gabriel P. Zonatto - 28.11.2021 06:41

I had a problem using the pivot model in many-to-many relationships because the queries in the database used the table name different from what I had named in the varialbe $table in model pivot

Ответить
rogger bm
rogger bm - 28.11.2021 02:14

you are a crack, my idol

Ответить
SkyNiitzs
SkyNiitzs - 26.11.2021 01:28

guys, this man is the best. Man thank you very much, you have saved me from a problem that I could not find how to solve it. Very good video and explained, it goes on so you will be much bigger than you are now.

Ответить
Emrane Klaaï
Emrane Klaaï - 09.11.2021 00:44

you saving my life ❤❤

Ответить
cédric vumisa
cédric vumisa - 12.10.2021 12:07

thank you very much

Ответить
Luis Rodriguez
Luis Rodriguez - 06.09.2021 08:50

very good and all, but you did not mention or show how to load with eagger loading the Belongs to Administrator, you load it from the view with $ project-> pivot-> administrator-> name and I understand that this is bad practice, I have tried to find the way to call the relationships that are in a pivot model but I have not had any luck, I only see that there are some packages for that, sorry for my English I speak Spanish.

Ответить
BadKing👑
BadKing👑 - 03.09.2021 04:38

it would be great if i can see source code on github or other git sites :D

Ответить
AL IMRAN SUJON
AL IMRAN SUJON - 27.08.2021 06:12

Another great video . Brilliant examples. Thanks a lot.

Ответить