Passed
Push — master ( 4a474d...df1b75 )
by Stephen
02:14
created

Team::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 2
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Sfneal\Users\Models;
4
5
use Illuminate\Database\Eloquent\Relations\BelongsTo;
6
use Sfneal\Models\AbstractModel;
7
use Sfneal\Models\Traits\CacheableAll;
8
use Sfneal\Scopes\OrderScope;
9
use Sfneal\Users\Scopes\UserActiveScope;
10
11
class Team extends AbstractModel
12
{
13
    use CacheableAll;
14
15
    /**
16
     * The "booting" method of the model.
17
     *
18
     * @return void
19
     */
20
    protected static function boot()
21
    {
22
        parent::boot();
23
24
        // Query scopes
25
        static::addGlobalScope(new OrderScope('order', 'asc'));
26
    }
27
28
    protected $connection = 'mysql';
29
    protected $table = 'team';
30
    protected $primaryKey = 'team_id';
31
32
    protected $fillable = [
33
        'team_id',
34
        'user_id',
35
        'order',
36
    ];
37
38
    /**
39
     * @var array Relationships that should be eager loaded with every query
40
     */
41
    protected $with = [
42
        'user',
43
        'user.file',
44
    ];
45
46
    /**
47
     * Team member's 'user' relationship.
48
     *
49
     * @return BelongsTo
50
     */
51
    public function user()
52
    {
53
        return $this->belongsTo(User::class, 'user_id', 'id')
54
            ->withoutGlobalScope(UserActiveScope::class);
55
    }
56
}
57