associations - How to create auto connection to language table [Article to Article_lang] -


i have idea.

we should create function auto connect class language class. ex: articles connect articles_lang.

default, have:

belongsto() hasone() hasmany() belongstomany() 

maybe, need add 1 more:

hasmultilangfields() 

ex:

class articlestable extends table {     public function initialize(array $config)     {         $this->addbehavior('timestamp');          $this->hasmultilangfields(['title', 'body']);     } } 

i want when using query in controller, auto find values articles_lang

class articlescontroller extends appcontroller {     public function view($id)     {         $article = $this->articles->get($id);         $this->set(compact('article'));     } } 

result:

$article->id = 12 $article->created = 2015-05-29t05:09:36+0000 $article->title = title 12 $article->body = body 12 

database:

= articles = id           |  int(10) primary created      |  datetime modified     |  datetime  = articles_lang = id_articles  |  int(11) id_lang      |  int(11) title        |  varchar(150) body         |  text 

how can this??

[...] maybe, need add 1 more

or maybe don't. not core supply translation functionality, there plugins out there handling this.


Comments