Level 70
@mtbc Isn't that you are not returning from the if statement during generating slug?
public static function generateslug() {
$slug = Str::random(6);
if (self::where('slug', $slug)->exists()) {
return self::generateslug();
}
return $slug;
}
And update your form() method like this:
public static function form(Form $form): Form {
return $form->schema([
Forms\Components\TextInput::make('slug')
->required()
->default(Jogo::generateslug()), // Call the method here
]);
}
3 likes