Completed
Push — dev ( d72849...45b7bd )
by Yan
03:48
created

Lincable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bootLincable() 0 4 1
A getLincableFields() 0 5 1
A addLincableFields() 0 5 1
1
<?php
2
3
namespace Lincable\Eloquent;
4
5
trait Lincable
6
{
7
    /**
8
     * Boot the model statically.
9
     * 
10
     * @return void
11
     */
12
    public static function bootLincable()
13
    {
14
        static::creating(function ($model) {
15
            $model->addLincableFields();
16
        });
17
    }
18
19
    /**
20
     * Add the lincable fields to model fillables.
21
     * 
22
     * @return void
23
     */
24
    public function addLincableFields()
25
    {
26
        $this->fillable(array_merge( 
0 ignored issues
show
Bug introduced by
It seems like fillable() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->/** @scrutinizer ignore-call */ 
27
               fillable(array_merge( 
Loading history...
27
            $this->getFillable(),
0 ignored issues
show
Bug introduced by
It seems like getFillable() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            $this->/** @scrutinizer ignore-call */ 
28
                   getFillable(),
Loading history...
28
            $this->getLincableFields()
29
        ));
30
    }
31
32
    /**
33
     * Return the fields to link the model.
34
     * 
35
     * @return array
36
     */
37
    public function getLincableFields()
38
    {
39
        return [
40
            'preview',
41
            'filename'
42
        ];
43
    }
44
}