Git Product home page Git Product logo

Comments (4)

dimsav avatar dimsav commented on July 26, 2024

Hi @mbouclas,

it is not safe to overwrite the constructor of the parent class. Could you explain what are you doing in the constructor?

Also, the syntax $newProduct->title = 'my test products'; is not valid after version 4, please use $newProduct->getTranslation('gr')->title = 'my test products'.

I am not able to understand why your code is not working, but since the package is well tested there is probably an error in your class. Try to remove the funky constructor and all the lines of code that might affect your issue.

from laravel-translatable.

mbouclas avatar mbouclas commented on July 26, 2024

The constructor is necessary to what I do. that is extend an abstract which
extends an eloquent model. This is how you extend models when you need to
add stuff to the models constructor without losing eloquent. In any event,
if you add a constructor, which is not an extreme case, and assign a
private there, your code adds it to the model, which shouldn't be the case.

from laravel-translatable.

dimsav avatar dimsav commented on July 26, 2024

I understand that you need the constructor in the class. Just try to remove it to see if this is what causes the problem with laravel-translatable. Then, put the constructor back.

Also, add parent::__construct($attributes) to your constructor, to not skip the constructor of eloquent.

Let me know what happens.

from laravel-translatable.

mbouclas avatar mbouclas commented on July 26, 2024

ok, found the problem. It has to do with how Eloquent boots the models. I was extending an abstract which was extending Eloquent. In the abstract i had the $ns declared but did not do the same on the extended class. When not using your trait everything seemed fine, but when adding the trait, i have to assume Eloquent, assumed that $ns is a property so it added it to the create query.
Redeclaring it to the extended class solved the problem.

Thank you for your time

from laravel-translatable.

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.