public static function bootSluggable()
    {
        static::creating(function ($model) {
            $model->generateSlug();
        });

        static::created(function ($model) {
            if ($model->slugStrategy() == 'id') {
                $model->generateIdSlug();
                $model->save();
            }
        });
    }
public static function bootSluggable()
    {
        static::creating(function ($model) {
            $model->generateSlug();
        });

        static::created(function ($model) {
            if ($model->slugStrategy() == 'id') {
                $model->generateIdSlug();
                $model->save();
            }
        });
    }
public static function bootSluggable ( ) { static :: creating ( function ( $ model ) { $ model -> generateSlug ( ) ; } ) ; static :: created ( function ( $ model ) { if ( $ model -> slugStrategy ( ) == 'id' ) { $ model -> generateIdSlug ( ) ; $ model -> save ( ) ; } } ) ; }
When added to a model, the trait will bind to the creating and created
events, generating the appropriate slugs as necessary.
When added to a model the trait will bind to the creating and created events generating the appropriate slugs as necessary .