Completed
Push — develop ( 47c344...98c724 )
by Martin
02:19
created

Rivet::getMorphToManyName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
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 getMorphToManyName()
39
    {
40
        return 'rivetable';
41
    }
42
43
    public static function getMorphToSortableManyOtherKey()
44
    {
45
        return null;
46
    }
47
}
48