Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kalendar-unesa
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Febry San
kalendar-unesa
Commits
83b4f371
Commit
83b4f371
authored
Mar 28, 2023
by
f3brysan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7: Auto Generate UUID
parent
a5d6c5c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
app/Traits/Uuid.php
+23
-0
No files found.
app/Traits/Uuid.php
0 → 100644
View file @
83b4f371
<?php
namespace
App\Traits
;
use
Illuminate\Support\Str
;
use
Ramsey\Uuid\Exception\UnsatisfiedDependencyException
;
trait
Uuid
{
protected
static
function
boot
()
{
parent
::
boot
();
static
::
creating
(
function
(
$model
)
{
try
{
$model
->
id
=
(
string
)
Str
::
uuid
();
// generate uuid
// Change id with your primary key
}
catch
(
UnsatisfiedDependencyException
$e
)
{
abort
(
500
,
$e
->
getMessage
());
}
});
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment