Passed
Push — master ( a958bc...8e2bab )
by Ron
01:34
created

World   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A galaxy() 0 3 1
A tycoons() 0 3 1
A worldTycoons() 0 3 1
A scopeInvestorCount() 0 3 1
A investors() 0 3 1
A scopeOnlineCount() 0 4 1
A online() 0 3 1
1
<?php
2
3
namespace Starpeace\Models\Eloquent\Common;
4
5
use Starpeace\Models\Eloquent\BaseModel;
6
7
class World extends BaseModel
8
{
9
    protected $table = 'worlds';
10
11
    protected $fillable = [ 'galaxy_id', 'map_id', 'name', 'display_name', 'use_whitelist', 'use_blacklist' ];
12
13
    protected $dates = [ 'created_at', 'updated_at' ];
14
15
    public function galaxy()
16
    {
17
        return $this->belongsTo(Galaxy::class, 'id', 'galaxy_id');
18
    }
19
20
    public function tycoons()
21
    {
22
        return $this->hasMany(WorldTycoon::class);
23
    }
24
25
    public function worldTycoons()
26
    {
27
        return $this->hasMany(WorldTycoon::class);
28
    }
29
30
    public function online()
31
    {
32
        return $this->hasMany(WorldTycoon::class);
33
    }
34
35
    public function investors()
36
    {
37
        return $this->hasMany(WorldTycoon::class);
38
    }
39
40
    public function scopeOnlineCount($query)
41
    {
42
        return $query->withCount(['online' => function ($query) {
43
            $query->online();
44
        }]);
45
    }
46
47
    public function scopeInvestorCount($query)
48
    {
49
        return $query->withCount('investors');
50
    }
51
}
52