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
*/
しばらくこれで立ち往生しています。どんな助けでも大歓迎です:-)