Giter VIP home page Giter VIP logo

Comments (2)

joaolisboa avatar joaolisboa commented on May 26, 2024

Well, nevermind my stupidity since there's a collection property for when creating attributes. I still have an issue though.

Testing in artisan tinker, and when I push a value and save the model, it doesn't update the collection. Example output from tinker:

>>> $product = Modules\Catalog\Models\Product::find(2);
=> Modules\Catalog\Models\Product {#3154
     id: 2,
     sku: "test",
     name: "test",
     family_id: 1,
     product_brand_id: 1,
     product_state_id: 1,
     created_at: null,
     updated_at: null,
     deleted_at: null,
     product_segment_id: 1,
     product_manager: 1,
     photo: null,
     attribute-1: Rinvex\Attributes\Models\Type\Integer {#3184
       id: 1,
       content: 23,
       attribute_id: 21,
       entity_id: 2,
       entity_type: "Modules\Catalog\Models\Product",
       created_at: "2018-06-06 23:46:22",
       updated_at: "2018-06-06 23:46:22",
     },
     attribute-1-fixed: null,
     attribute-1-1: null,
     description: Rinvex\Attributes\Models\Type\Varchar {#3194
       id: 1,
       content: "descrição produto #2",
       attribute_id: 24,
       entity_id: 2,
       entity_type: "Modules\Catalog\Models\Product",
       created_at: null,
       updated_at: null,
     },
     file: null,
     file-1: null,
     option: App\Models\Option {#3216
       id: 1,
       content: 2,
       attribute_id: 27,
       entity_id: 2,
       entity_type: "Modules\Catalog\Models\Product",
       created_at: "2018-06-06 23:46:22",
       updated_at: "2018-06-06 23:46:22",
     },
     options: Rinvex\Attributes\Support\ValueCollection {#3228
       all: [
         App\Models\Options {#3229
           id: 1,
           content: 1,
           attribute_id: 29,
           entity_id: 2,
           entity_type: "Modules\Catalog\Models\Product",
           created_at: "2018-06-07 00:08:39",
           updated_at: "2018-06-07 00:08:39",
         },
       ],
     },
   }


>>> $product->options->push("2")
=> Illuminate\Support\Collection {#3077
     all: [
       "1",
       "2",
     ],
   }


>>> $product->options
=> Illuminate\Support\Collection {#3141
     all: [
       "1",
     ],
   }


>>> $product->save()
=> true

>>> $product->options
=> Illuminate\Support\Collection {#3225
     all: [
       "1",
     ],
   }

from laravel-attributes.

Omranic avatar Omranic commented on May 26, 2024

This has been completely refactored in a different branch here:
https://github.com/rinvex/laravel-attributes/tree/refactor-to-native-laravel-relationships

In the new refactor, it actually uses normal relationships, and should be easy and straightforward like default Laravel relationships. Although, that refactor is incomplete. Any help with that branch would be much appreciated! 🙂

from laravel-attributes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.