我已经使用了这种“ cviebrock /雄辩的可拖拉” laravel软件包,我需要生成这样的产品塞子
名称:红色衬衫
插入:红色衬衫520(520是红色衬衫产品的记录ID)
以下是用于生成弹头但无法正常工作的模型函数
public function sluggable()
{
return [
'slug' => [
'source' => ['name', 'tbl_products.id'],
'separator' => '-',
'onUpdate' => true,
]
];
}
答案 0 :(得分:0)
在模型文件中添加如下所示的代码,并将插件详细信息添加到config / app.php provider数组中 Cviebrock \ EloquentSluggable \ ServiceProvider :: class,
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Sluggable;
public function sluggable() {
return ['slug'=>[
'source'=>'full_name',
'onUpdate'=>true
]];
}
}