Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
afsakar committed Sep 17, 2024
1 parent f3548f2 commit ebb2d29
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions src/Filament/Resources/FormBuilderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,7 @@ public static function form(Form $form): Form
->hintIcon('heroicon-s-information-circle', 'Kısa Ad sadece alan oluşturulduğunda otomatik olarak oluşturulur. Kullanıcı için herhangi bir etkisi yoktur.')
->unique('form_builders', 'slug', ignoreRecord: true)
->dehydrateStateUsing(function ($state) {
$slug = str($state)->slug();
$existingSlugs = FormBuilder::where('slug', 'LIKE', "{$slug}%")
->pluck('slug');

if ($existingSlugs->contains($slug)) {
$numbers = $existingSlugs->map(function ($existingSlug) use ($slug) {
if (preg_match('/' . preg_quote($slug, '/') . '-(\d+)$/', $existingSlug, $matches)) {
return intval($matches[1]);
}

return null;
})->filter()->sort()->values();

if ($numbers->isNotEmpty()) {
$newNumber = $numbers->last() + 1;
} else {
$newNumber = 2;
}

return $slug . '-' . $newNumber;
}

return $slug;
return Str::slug($state);
})
->required(),
self::hiddenFormBuilderLabels(),
Expand Down

0 comments on commit ebb2d29

Please sign in to comment.