Laravel Advanced - Polymorphic Relationship

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • Let's be friends:
    / aashish_dhamala
    Github Repo:
    Please read the readme to access the code for the specific video.
    github.com/lar...
    Laravel 8 Advanced - Has One Relationship
    • Laravel Advanced - Has...
    Laravel 8 Advanced - Has Many Relationship
    • Laravel Advanced - Has...
    In this video, I have discussed the has many polymorphic relationship.
    A polymorphic relationship allows the target model to belong to more than one type of model using a single association.
    In a one to many polymorphic relationship, the target model can belong to more than one type of model on a single association. For example, imagine users of your application can "comment" on both posts and products. Using polymorphic relationships, you may use a single comments table for both of these scenarios.

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

  • @Laratips
    @Laratips  4 года назад +3

    We have a lot of benefits when using polymorphic relationship. However, we have one disadvantage that we will not be able to use the foreign key here.

    • @lucadifazio2735
      @lucadifazio2735 3 года назад

      That was exactly what I was looking for. So do I need to write the foreign keys manually?

  • @dhanushkafernando6316
    @dhanushkafernando6316 3 года назад

    Usefull

  • @lijahtech8200
    @lijahtech8200 3 года назад

    Nice video, thanks.

  • @ashwagjan4532
    @ashwagjan4532 3 года назад

    you are an awesome teacher

  • @bobbyiliev_
    @bobbyiliev_ 3 года назад

    Great video! Well done.

  • @renejguerra8089
    @renejguerra8089 2 года назад

    What about many to many?

    • @Laratips
      @Laratips  2 года назад

      I have video on all the relationship in laravel. You can check my channel

  • @mmsskk1413
    @mmsskk1413 3 года назад

    Wonderful Video

    • @Laratips
      @Laratips  3 года назад +1

      Thank you! Cheers!