Trying out cviebrokc/eloquent-sluggable I've tried accessing the Eloquent through a blade view, echoing out the slug of a post to link to. The database table, using sqlite, has a slug column but getting the posts through Eloquent and dumping a $post->getSlug()
returns NULL
. It's setup as following:
In my blade view:
@foreach (Posts::get() as $post)
{{ var_dump( $post->getSlug() ) }}
@endforeach
And in my Posts.php model:
<?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',
);
}
Should I assign it as a new instance, if so, how? Or how would I go about doing it?