Code Monkey home page Code Monkey logo

Comments (4)

sdebacker avatar sdebacker commented on May 31, 2024

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.

sangar82 avatar sangar82 commented on May 31, 2024

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.

sangar82 avatar sangar82 commented on May 31, 2024

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.

sangar82 avatar sangar82 commented on May 31, 2024

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)

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.