Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117748886
UuidStrKeyTrait.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
UuidStrKeyTrait.php
View Options
<?php
namespace
App\Traits
;
trait
UuidStrKeyTrait
{
/**
* Boot function from Laravel.
*/
protected
static
function
bootUuidStrKeyTrait
()
{
static
::
creating
(
function
(
$model
)
{
if
(
empty
(
$model
->{
$model
->
getKeyName
()}))
{
$allegedly_unique
=
\App\Utils
::
uuidStr
();
// Verify if unique
if
(
in_array
(
'Illuminate
\D
atabase
\E
loquent
\S
oftDeletes'
,
class_uses
(
$model
)))
{
while
(
$model
->
withTrashed
()->
find
(
$allegedly_unique
))
{
$allegedly_unique
=
\App\Utils
::
uuidStr
();
}
}
else
{
while
(
$model
->
find
(
$allegedly_unique
))
{
$allegedly_unique
=
\App\Utils
::
uuidStr
();
}
}
$model
->{
$model
->
getKeyName
()}
=
$allegedly_unique
;
}
});
}
/**
* Get if the key is incrementing.
*
* @return bool
*/
public
function
getIncrementing
()
{
return
false
;
}
/**
* Get the key type.
*
* @return string
*/
public
function
getKeyType
()
{
return
'string'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 1:15 AM (1 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d4/dd/2c430b4e883e2fa0f41494800253
Default Alt Text
UuidStrKeyTrait.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline