We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbf914e commit 8fb4defCopy full SHA for 8fb4def
README.md
@@ -23,3 +23,15 @@ class Project extends Model
23
If your column name is not "uuid", simply add a new property to your model named "uuidFieldName":
24
25
protected $uuidFieldName = 'unique_id';
26
+
27
+This trait also adds a scope:
28
29
+```
30
+\App\Project::byUUID('uuid')->first();
31
32
33
+And static find method:
34
35
36
+\App\Project::findByUUID('uuid')
37
src/Traits/HasUUID.php
@@ -24,4 +24,12 @@ public static function generateUUID(){
return \Uuid::generate()->string;
}
+ public function scopeByUUID($query, $uuid){
+ return $query->where($this->getUUIDFieldName(),$uuid);
+ }
+ public static function findByUuid($uuid){
+ return static::byUUID($uuid)->first();
0 commit comments