将 Anahkiasen/Polyglot 包添加到我的 Laravel 4.2 项目后,我试图让它工作。我按照我认为应该的方式设置了所有内容(文档有点糟糕)。保存到数据库似乎不是问题,但是当我想阅读时,出现以下错误:
Trying to get property of non-object (View: /Applications/MAMP/htdocs/*my view*.blade.php)
楷模:
use Polyglot\Polyglot;
class Page extends Polyglot {
use SoftDeletingTrait;
protected $fillable = [
'lang',
'meta_title',
'meta_description',
'title',
'page_title',
'page_content',
];
protected $polyglot = [
'meta_title',
'meta_description',
'title',
'page_title',
'page_content',
];
// ...
}
class PageLang extends Eloquent {
public $timestamps = false;
protected $fillable = [
'page_id',
'lang',
'meta_title',
'meta_description',
'title',
'page_title',
'page_content',
];
}
我的刀片模板:
$page->nl->title
/*
This is what's causing the error
$page->title doesn't produce errors but is, of course, empty
*/
一直停留在这个问题上。任何帮助是极大的赞赏 :-)