Roman_applicant-site/app/Helpers/SlugHelper.php

19 lines
415 B
PHP
Raw Normal View History

2024-03-12 12:40:40 +03:00
<?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'];
}
}