Completed
Pull Request — master (#3)
by
unknown
01:18
created

HasConfigModel::bootHasUuid()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
3
4
namespace RexlManu\LaravelTickets\Traits;
5
6
/**
7
 * Trait HasConfigModel
8
 *
9
 * Is used internal for using configuration elements
10
 *
11
 * @package RexlManu\LaravelTickets\Traits
12
 */
13
trait HasConfigModel
14
{
15
16
    public function getKeyType()
17
    {
18
        return config('laravel-tickets.models.key-type');
19
    }
20
21
    public function isIncrementing()
22
    {
23
        return config('laravel-tickets.models.incrementing');
24
    }
25
    
26
    public static function bootHasUuid()
27
    {
28
        if(config('laravel-tickets.models.uuid')) {
29
            static::creating(function ($model) {
30
                if (empty($model->id)) {
31
                    $model->id = Uuid::uuid4();
32
                }
33
            });
34
        }
35
    }
36
    
37
}
38