Travel::setAttribute()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 2
crap 12
1
<?php
2
3
namespace SET;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Travel extends Model
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $table = 'travels';
13
    /**
14
     * @var bool
15
     */
16
    public $timestamps = true;
17
    /**
18
     * @var array
19
     */
20
    protected $fillable = ['location', 'brief_date', 'debrief_date', 'leave_date', 'return_date', 'comment', 'is_ready', 'author_id', 'user_id'];
21
22
    public function user()
23
    {
24
        return $this->belongsTo('SET\User');
25
    }
26
27
    public function author()
28
    {
29
        return $this->belongsTo('SET\User', 'author_id');
30
    }
31
32
    public function attachments()
33
    {
34
        return $this->morphMany('SET\Attachment', 'imageable');
35
    }
36
37
    /**
38
     * @param string $key
39
     * @param mixed  $value
40
     *
41
     * @return $this
42
     */
43 View Code Duplication
    public function setAttribute($key, $value)
44
    {
45
        if (is_scalar($value) && $value === '') {
46
            $value = null;
47
        }
48
49
        return parent::setAttribute($key, $value);
50
    }
51
}
52