layfi-earn/vendor/illuminate/database/Eloquent/Concerns/HasUlids.php
2025-01-27 20:49:47 +08:00

32 lines
536 B
PHP

<?php
namespace Illuminate\Database\Eloquent\Concerns;
use Illuminate\Support\Str;
trait HasUlids
{
use HasUniqueStringIds;
/**
* Generate a new unique key for the model.
*
* @return string
*/
public function newUniqueId()
{
return strtolower((string) Str::ulid());
}
/**
* Determine if given key is valid.
*
* @param mixed $value
* @return bool
*/
protected function isValidUniqueId($value): bool
{
return Str::isUlid($value);
}
}