Completed
Push — develop ( 9ee49b...09fe33 )
by Martin
02:19
created

Rivet::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Luminark\Rivet\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Luminark\SerializableValues\Traits\HasSerializableValuesTrait;
7
use Luminark\Rivet\Models\Scopes\RivetTypeScope;
8
use Illuminate\Support\Str;
9
10
/**
11
 * @property string type
12
 * @property array values
13
 * @property stdClass file
14
 */
15
class Rivet extends Model
16
{
17
    use HasSerializableValuesTrait;
18
    
19
    public static function boot()
20
    {
21
        parent::boot();
22
        
23
        if (static::class == Rivet::class) {
24
            static::addGlobalScope(new RivetTypeScope(static::class));
25
            static::saving(function ($model) {
26
                $model->type = static::class;
27
            });
28
        }
29
    }
30
    
31
    protected $fillable = ['values'];
32
    
33
    protected function getSerializableAttributes()
34
    {
35
        return ['file'];
36
    }
37
    
38
    public static function getMorphToSortableManyOtherKey()
39
    {
40
        return null;
41
    }
42
}
43