Conditions | 4 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | public function scopeUuid($query, $uuid, $first = true) |
||
33 | { |
||
34 | $match = preg_match('/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/', $uuid); |
||
35 | |||
36 | if (!is_string($uuid) || $match !== 1) |
||
37 | { |
||
38 | throw (new ModelNotFoundException)->setModel(get_class($this)); |
||
39 | } |
||
40 | |||
41 | $results = $query->where(config('uuid.default_uuid_column'), $uuid); |
||
42 | |||
43 | return $first ? $results->firstOrFail() : $results; |
||
44 | } |
||
45 | |||
46 | } |