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

Popular posts from this blog

Use the Google Custom Search JSON API to retrieve images

Terminal commands relared to files in the Ubuntu

Development-Testing Workflow