Laravel Advanced - Many To Many Relationship
HTML-код
- Опубликовано: 3 июл 2024
- Let's be friends:
/ aashish_dhamala
Github Repo:
Please read the readme to access the code for the specific video.
github.com/laratipsofficial/l...
Carbon docs:
carbon.nesbot.com/docs/
Many-to-many relations are slightly more complicated than hasOne and hasMany relationships. An example of such a relationship is a user with many roles, where the roles are also shared by other users. For example, many users may have the role of "Admin".
In this video, I have discussed the many to many relationship in Laravel.
- Access related models using many to many relation
- Save, update and, delete related models
- List the related models
- Lazy or Eager load the related models
- Optimize and improve your app performance by reducing n+1 problem
One of the best explanation of ManyToMany relationship. Awesome 🌟
Very comprehensive tutorial. Thank you.
Very well explained.Easy to understand.Never stop this good work.
Thanks
Good Tutorial, Excellent bro. Thank you
Good job thanks for share with us.
Please continue this man, we're supporting you
Thank you so much 🙂
@@Laratips this is a quality content, continue making Laravel and Vue Js tutorials and tips
Very nice, thanks from Brazil
Wow. Thanks
If I want to display user according to there role ..for example. Want to show all admin in a page with there information. How am I going to go about it ..?
Awesome content! Subscribed. Haha. Your video helped me understood this manytomany relationship which I am going to implement in my project. Also, what extension do you use for laravel in browser there?
Awesome, glad that I could helped you.
Also, it is not extension. It is a laravel package. Here's the link:
github.com/barryvdh/laravel-debugbar
you are great teacher , Please could you do Project based tutorial
Thanks. I will do in the future
WOW! You are amazing. I love this because its so easy to follow you. :D Do you have a tutorial for tinkerwell? I think this is good for learning, the laravel relations. Please more content ;)
Glad that you liked it.
I don't have a tutorial for tinkerwell yet. Thanks for the idea. I will add that in my todo list.
i got confused with cleared concepts!!
In which part did you get confused? Can u plz tell me in detail so that i can help
Hello. Can you make video on many to many polymorphic relationship with querying different data ?
I thought I have already made a video about that. Thanks for mentioning. I will add it to the todo list.
@@Laratips Also, like one to many polymorphic relationship video, please add different example and db related queries.
any advice on how to attach image on pivot table sir ?
You can store the image and save the path of the image as string.
@@Laratips
$employee = \App\Models\Employee::find($id);
$seaman->document()->attach($request->document_id,[
'att_number' =>$request->att_number,
'att_by' =>$request->att_by,
'image' =>$request->iamge,
]);
$fileName = time().'.'.$request->attach_file->extension();
$request->attach_file->move(public_path('file_upload'), $fileName);
so far i could only manage like this, the image got its name but didnt get attached to DB,
You need to first store the image to the filesystem and then attach it's name. You are doing opposite here. Pass the $imageName to the attach method instead of request.
Also, don't forget to add 'image' inside the 'withPivot' method in the model relationship method.