Laravel Many to Many Relationship | Eloquent Many to Many | Laravel 9 Tutorial for Beginners

Поделиться
HTML-код
  • Опубликовано: 6 июл 2024
  • This tutorial will show you how the Laravel Many to Many Relationship works. We will be using Eloquent to demonstrate the Many to Many relationship - Want to learn the most popular PHP framework? Watch this Laravel 9 tutorial for beginners video series. Laravel makes your development process a lot easier without sacrificing your applications functionalities.
    📚 New Udemy Course
    If you're looking to level up your Laravel skills, my new course "Udemy Migirations, Seeders, Factories, Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/course/masterin...
    📲 Let’s plan a meeting
    Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews or a coaching session for Laravel. Please read the description before booking: calendly.com/codewithdary
    💌 Newsletter
    Sign up for my free weekly email newsletter: www.newsletter.codewithdary.com
    🔥 Resources
    - PHP Hosting (10% DISCOUNT): www.hostinger.com/codewithdary
    - TikTok: / codewithdary
    - Instagram: / codewithdary
    - Twitter: / codewithdary
    - Blog: blog.codewithdary.com/
    - Newsletter: newsletter.codewithdary.com/
    - Patreon: www.patreon.com/user?u=30307830
    - GitHub: github.com/codewithdary/larav...
    🔗 Useful links
    - Laravel 8 Course: • Complete Laravel Tutor...
    📋 Table of Content
    00:00 - Introduction
    01:11 - Category model & migration
    01:41 - Defining our first pivot table
    04:37 - Adding data inside the database
    06:28 - Defining relationships
    07:37 - Outputting data in the browser
    #laravel #framework #php #laravel9

Комментарии • 32

  • @tacanda6479
    @tacanda6479 Год назад +3

    This tutorial is even more straight forward than the one on Laracast 👍

  • @syaoranpt
    @syaoranpt 3 месяца назад +1

    The video explains it very well, but I was kinda hoping you would explain how to use many-to-many relation together with seeders, that's the more complicated stuff, at least for me. :)
    Great explanations as usual! Love your videos.

    • @codewithdary
      @codewithdary  3 месяца назад

      The video title and description does not say anything about that 😅. Anyways thank you for watching and your kind words :)

  • @dereksolutionsrobins7117
    @dereksolutionsrobins7117 6 месяцев назад +1

    good! october cms documentation is crap, this worked like a charm

  • @VadimBesedin
    @VadimBesedin Год назад +3

    Thank you for the clear explanation. Great style of teaching.
    How do you edit data in SQL tables inside of VS Code, is it some kind of extension?

    • @codewithdary
      @codewithdary  Год назад +4

      Hi Vadim. Thank you so much :)
      I'm using an extension named Database Client, you can find it right here: ruclips.net/video/4dId4tpEYII/видео.html

    • @VadimBesedin
      @VadimBesedin Год назад

      @@codewithdary Thank you! Keep it up with your great videos! You helping a lot of people.

  • @sedatozcelik3789
    @sedatozcelik3789 Год назад +1

    Hi there can you suggest vscode packet for better experience when you write code. Especially; the one about migration file belongsToMany complition at 7.34 is lovely.

    • @codewithdary
      @codewithdary  Год назад

      It's better to watch the third video from this video series where I setup Visual Studio Code: ruclips.net/video/KAUxgUvC514/видео.html

  • @fernandezjasper
    @fernandezjasper 6 месяцев назад +1

    Great Video!, now how about 3 foreign keys to the pivot table?

    • @codewithdary
      @codewithdary  6 месяцев назад

      In what scenario? A pivot table in Laravel can have multiple foreign keys depending on the relationship it represents. It is possible to have a pivot table with 3 foreign keys if the relationship requires it.

  • @lowelltebrero931
    @lowelltebrero931 Год назад

    how about the attach, sync dettach ?

  • @kipkoechhillary3371
    @kipkoechhillary3371 Год назад +1

    the best tutoral dary!!

  • @lunaer-6555
    @lunaer-6555 9 месяцев назад +1

    really helpful, thank you :D

  • @olcayergul
    @olcayergul Год назад +1

    what is the advantages of pivot table in a such case post - caregories? I mean we could create a field like category_id in posts table and we could add a foreign key which references id in the categories table. That what i do usually in my projects.
    Could you explain why do we need pivot table for category and posts? What are the advantages and disadvantages your way and my way?

    • @codewithdary
      @codewithdary  Год назад

      If you add the category_id inside the posts table you can't have a many to many relationship. That means you have to duplicate an entire post just to change the category_id inside the posts table. I think you are confused with another relationship!

    • @olcayergul
      @olcayergul Год назад

      @@codewithdary oh you are right. My scenario was about one post can belong to only one category. In your scenario, the user can assign multiple category to a post. Got it.

    • @stewarty114
      @stewarty114 Год назад

      @@olcayergul but if you have post_id in your category table you can have a one to many relationship. This is simpler but the problem is you end up with repeating category names - bad for storage and performance when it comes to GB category tables

  • @ramym.moustafa2507
    @ramym.moustafa2507 Год назад +1

    Please Can I Ask you about your VSCode Extensions and theme you use?

    • @codewithdary
      @codewithdary  Год назад

      You can find everything right here: ruclips.net/video/KAUxgUvC514/видео.html&t

  • @randomvariable8680
    @randomvariable8680 Год назад +1

    man could you please tell which vs code theme this is? looks slick

    • @codewithdary
      @codewithdary  Год назад

      I think it is Material Theme Palenight. Here's the video where I set it up: ruclips.net/video/KAUxgUvC514/видео.html&t

  • @jack-sx9bw
    @jack-sx9bw Год назад

    which extension of database u are using thx

  • @tacanda6479
    @tacanda6479 Год назад +1

    We need a tutorial where we can upload video files instead of picture files.

    • @codewithdary
      @codewithdary  Год назад

      spatie.be/courses/discovering-laravel-media-library