19 lines
415 B
PHP
19 lines
415 B
PHP
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
class SlugHelper
|
|
{
|
|
public static function get(array $validated): string
|
|
{
|
|
if ($validated['slug'] === null) {
|
|
$transliterationSlug = Str::slug($validated['name']);
|
|
$randomNumber = random_int(100, 999);
|
|
return "{$transliterationSlug}-{$randomNumber}";
|
|
}
|
|
return $validated['slug'];
|
|
}
|
|
}
|