How to create slug
In php laravel
use Illuminate\Support\Str;
class Post extends Model
{
protected $fillable = ['title', 'content', 'slug'];
public static function boot() {
parent::boot();
static::creating(function ($post) {
$post->slug = Str::slug($post->title);
});
}
}
https://chatgpt.com/share/679dae98-24e8-8001-b0d5-02f4b60cb8e3
Comments
Post a Comment
What is your thought about this?