Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    Polymorphic Relations In Laravel

    Back-End Development
    laravel database relationship
    2
    5
    1307
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fern Node.js last edited by

      anyone can explain about larvel polymorphic relationship?

      1 Reply Last reply Reply Quote 1
      • root
        root Linux Help last edited by root

        "A polymorphic relationship allows the target model to belong to more than one type of model using a single association."
        

        That means you can associate one(1) table (Model) for different situations.

        Ex : Facebook has comments for Images and Videos, In the backend Facebook only has one "comments" table for both Images & Videos.

        And also this relationship can work with other relationships in Eloquent ORM

        • One To One (Polymorphic)
        • One To Many (Polymorphic)
        • Many To Many (Polymorphic)

        https://laravel.com/docs/5.7/eloquent-relationships#polymorphic-relationships

        1 Reply Last reply Reply Quote 2
        • F
          fern Node.js last edited by

          thank you bro, can you post sample code snippet for model?

          root 1 Reply Last reply Reply Quote 0
          • root
            root Linux Help @fern last edited by

            @fern you can find it on below url..

            1 Reply Last reply Reply Quote 1
            • F
              fern Node.js last edited by

              thank you, I'll find out :smile:

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              0
              Online

              3.7k
              Users

              1.3k
              Topics

              5.3k
              Posts

              • Privacy
              • Terms & Conditions
              • Donate

              © Copyrights and All right reserved Lanka Developers Community

              Powered by Axis Technologies (PVT) Ltd

              Made with in Sri Lanka

              | |