Comments (4)
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.
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.
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.
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)
- Add Laravel 5.8 support HOT 1
- Saving in translated model instead of saving in original model HOT 4
- Fetching Model by translated field and determine locale HOT 3
- Extra Fields or Properties For Translated Text HOT 2
- Can't translate to Portuguese HOT 3
- Display translated attribute even if no translation for current locale and fallback locale? HOT 3
- Has this package a possibility to get translations of related models HOT 2
- Ability to save in both languages HOT 8
- ID coming back with different data HOT 4
- Query where locale not working properly HOT 2
- What would be the best way to handle admin panel with translations? HOT 4
- how i can custom $translatedAttributes from outside model HOT 2
- Multiple Databases HOT 2
- Fallback to default locale with numeric field is not working as expected HOT 3
- get all and Fallback if translation is missing #23 HOT 2
- Wrong column name HOT 2
- Problem with relations HOT 3
- Prefix for default language HOT 6
- When I change local I don't get the translation HOT 7
- how to change the category translation on the fly? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-translatable.