Bagisto Forum

    Bagisto

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

    Use registerModel if it is already used by another package same contract model

    General Discussion
    2
    4
    1204
    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.
    • ILDaviz
      ILDaviz last edited by

      Heeelllooo!
      I am using package: Bagisto Graphql.
      When I extend my product model from my package I see that in blade $products it is extended from "ACME\HelloWorld\Models\Webkul\Product\Models\Product" not from my model "ACME\HelloWorld\Models\Product
      ".
      If I remove the line form provider of Graphql package

      This line...
      // Catalog Product Models
      $this->app->concord->registerModel(\Webkul\Product\Contracts\Product::class, \Webkul\GraphQLAPI\Models\Catalog\Product::class);
      

      In this case I see my own model and not the Graphql model "ACME\HelloWorld\Models\Product
      "
      Here is the question but can I extend a model if it is already extended by another package?
      Is a problem of the Graphql packet that doesn't go a proxy?

      1 Reply Last reply Reply Quote 0
      • ILDaviz
        ILDaviz last edited by

        There is a question of the position order of the module to see who takes precedence in the registerModel?

        1 Reply Last reply Reply Quote 0
        • ILDaviz
          ILDaviz last edited by

          I solved it! You extend the last extended model of a specific class. By using the registerModel you link your new one with the last extended one. You have to be careful with the order of the providers in app.php as concord registers the connection with the key value so if it is not in the correct order your model will not be shown.

          1 Reply Last reply Reply Quote 0
          • N
            Naresh-webkul last edited by

            HI @ILDaviz ,
            Excactly, you need to define your service provider after the default modul service provider to override the existing models.
            Thanks!

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