Completed
Pull Request — master (#96)
by Brandon
02:26
created

Site::createSite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\DB;
7
use Spatie\Activitylog\Traits\LogsActivity;
8
9
class Site extends Model
10
{
11
    use LogsActivity;
12
    
13
    /**
14
     * The attributes that are mass assignable.
15
     *
16
     * @var array
17
     */
18
    protected $fillable = [
19
        'name'
20
    ];
21
    
22
    /**
23
     * The attributes to ignore in the Activity Log
24
     *
25
     * @var array
26
     */
27
    protected static $ignoreChangedAttributes = ['updated_at'];
28
    
29
    /**
30
     * The attributes to log in the Activity Log
31
     *
32
     * @var array
33
     */
34
    protected static $logAttributes = [
35
        'name'
36
    ];
37
    
38
    /**
39
     * Only log those that have actually changed after the update.
40
     *
41
     * @var array
42
     */
43
    protected static $logOnlyDirty = true;
44
    
45
    /**
46
     * Update the updated_at and created_at timestamps?
47
     *
48
     * @var array
49
     */
50
    public $timestamps = true;
51
    
52
    /**
53
     * Get the locations for the site.
54
     */
55
    public function locations()
56
    {
57
        return $this->hasMany('App\Location');
58
    }
59
    
60
    /**
61
     * Get the devices for the site.
62
     */
63
    public function devices()
64
    {
65
        return $this->hasManyThrough('App\Device', 'App\Location');
66
    }
67
}
68