Comments (4)
I also have News and NewsTranslation models and no problem for me. Your migrations seems to be ok. The problem should be somewhere else.
from laravel-translatable.
I add my models too
<?php
class News extends Eloquent {
use \Dimsav\Translatable\Translatable;
public $translatedAttributes = array('title', 'description', 'subtitle', 'youtube');
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'news';
/**
* Attributes allowed for massive assignament
*
* @var array
*/
protected $fillable = array('publication_date', 'image', 'author', 'entity_id');
/**
* Create validation rules
*
* @var array
*/
public static $rules = array(
'publication_date' => 'required',
'image' => 'mimes:jpeg,bmp,png|max:2048',
'author' => 'max:50',
'entity_id' => 'numeric|required',
);
/**
* Update validation rules
*
* @var array
*/
public static $rulesedit = array(
'publication_date' => 'required',
'image' => 'mimes:jpeg,bmp,png|max:2048',
'author' => 'max:50'
);
<?php
class NewsTranslation extends Eloquent {
public $timestamps = false;
protected $fillable = ['title', 'subtitle', 'description', 'youtube'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'news_translations';
}
from laravel-translatable.
And a example of create news array
array (size=7)
'publication_date' => string '2014-07-31 08:00:00' (length=19)
'image' =>
object(Symfony\Component\HttpFoundation\File\UploadedFile)[9]
private 'test' => boolean false
private 'originalName' => string 'Folder.jpg' (length=10)
private 'mimeType' => string 'image/jpeg' (length=10)
private 'size' => int 35416
private 'error' => int 0
'author' => string 'author_name' (length=11)
'entity_id' => string '1' (length=1)
'ca' =>
array (size=4)
'title' => string 'bla' (length=3)
'description' => string 'gla' (length=3)
'subtitle' => string 'pla' (length=3)
'youtube' => string 'vla' (length=3)
'es' =>
array (size=4)
'title' => string 'ble' (length=3)
'description' => string 'gle' (length=3)
'subtitle' => string 'ple' (length=3)
'youtube' => string 'vle' (length=3)
'en' =>
array (size=4)
'title' => string 'bli' (length=3)
'description' => string 'gli' (length=3)
'subtitle' => string 'pli' (length=3)
'youtube' => string 'vli' (length=3)
$news = $this->news->create($data);
from laravel-translatable.
I think that i found the error: I didn't add on the News Model fillable array the translated names
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.