-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference id is 0 #433
Comments
Hi, @nkhoangvu! For your problem, I suggest changing the array format for creating a post or changing the configuration to use a wrapper for transaltions. If you need more information, see below. By default, if you need to create a post with translations, you must pass an array with one of the next formats (see more on usage/forms: 1 - using array format $post->fill([
'en' => [
'title' => 'My first edited post',
],
'de' => [
'title' => 'Mein erster bearbeiteter Beitrag',
],
]); Example from test - https://github.com/Astrotomic/laravel-translatable/blob/main/tests/TranslatableTest.php#L210-L225 2 - using plain (with colon) format $post->fill([
'title:en' => 'My first edited post',
'title:de' => 'Mein erster bearbeiteter Beitrag',
]); Example from test - https://github.com/Astrotomic/laravel-translatable/blob/main/tests/TranslatableTest.php#L112-L123 From the latest versions of a package, you can use a new format, with a wrapper for translations (see in docs) $data = [
'author' => 'Gummibeer',
'translations' => [
'en' => ['title' => 'My first post'],
'fr' => ['title' => 'Mon premier post'],
],
];
$post = Post::create($data); Example from test - https://github.com/Astrotomic/laravel-translatable/blob/main/tests/TranslatableTest.php#L228-L247 |
None of above method can help.
and this:
Note that the post_id is varchar(8) and not auto-increment and I only need to update only one language at a time depend on session language session('locale'). Below is my Post model:
|
Ok, I will check it later. |
I don't know this is a bug or I did not find the properly to handle the package. If the id of Post is input manually by form:
then:
The translation is excuted automatically in the same way with $post = Post::update($input) but the value of post_id cannot get properly, it always is 0, Although at that moment the new record $post was already created in DB.
Although I tried:
But no success.
How should I overcome this situation. Thank you.
Note: Everything works properly if the id is auto increment.
Versions (please complete the following information)
The text was updated successfully, but these errors were encountered: