Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120836897
UuidIntKeyTrait.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
UuidIntKeyTrait.php
View Options
<?php
namespace
App\Traits
;
use
App\Utils
;
trait
UuidIntKeyTrait
{
/**
* Boot function from Laravel.
*/
protected
static
function
bootUuidIntKeyTrait
()
{
static
::
creating
(
static
function
(
$model
)
{
if
(
empty
(
$model
->{
$model
->
getKeyName
()}))
{
$allegedly_unique
=
Utils
::
uuidInt
();
// Verify if unique
if
(
in_array
(
'Illuminate
\D
atabase
\E
loquent
\S
oftDeletes'
,
class_uses
(
$model
)))
{
while
(
$model
->
withTrashed
()->
find
(
$allegedly_unique
))
{
$allegedly_unique
=
Utils
::
uuidInt
();
}
}
else
{
while
(
$model
->
find
(
$allegedly_unique
))
{
$allegedly_unique
=
Utils
::
uuidInt
();
}
}
$model
->{
$model
->
getKeyName
()}
=
$allegedly_unique
;
}
});
}
/**
* Get if the key is incrementing.
*
* @return bool
*/
public
function
getIncrementing
()
{
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:37 PM (2 h, 25 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
69/f3/7b73e2eedfa58b4a88e7edbbbb07
Default Alt Text
UuidIntKeyTrait.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline