1
試用cviebrokc/eloquent-sluggable我嘗試通過刀片視圖訪問雄辯,迴應鏈接到一個帖子的slu slu。數據庫表,使用sqlite,有一個slug列,但通過Eloquent獲取帖子並傾銷$post->getSlug()
返回NULL
。這是設置如下:cviebrock/eloquent-sluggable返回null getSlug()
在我的刀片觀點:
@foreach (Posts::get() as $post)
{{ var_dump($post->getSlug()) }}
@endforeach
在我Posts.php模型:
<?php
use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;
class Posts extends Eloquent implements SluggableInterface{
use SluggableTrait;
protected $sluggable = array(
'build_from' => 'title',
'save_to' => 'slug',
);
}
我應該將其指定爲一個新的實例,如果是的話,怎麼樣?或者我會怎麼去做呢?