Completed
Push — master ( d44289...5243e0 )
by claudio
04:05
created

Group   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 70%

Importance

Changes 11
Bugs 3 Features 0
Metric Value
wmc 6
c 11
b 3
f 0
lcom 1
cbo 2
dl 0
loc 57
ccs 7
cts 10
cp 0.7
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlannerNameAttribute() 0 6 3
A employees() 0 4 1
A planner() 0 4 1
A company() 0 4 1
1
<?php
2
3
namespace plunner;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Group
9
 *
10
 * @package plunner
11
 * @author Claudio Cardinale <[email protected]>
12
 * @copyright 2015 Claudio Cardinale
13
 * @version 1.0.0
14
 * @property integer $id
15
 * @property \Carbon\Carbon $created_at
16
 * @property \Carbon\Carbon $updated_at
17
 * @property string $name
18
 * @property string $description
19
 * @property integer $company_id
20
 * @property integer $planner_id
21
 * @property-read mixed $planner_name
22
 * @property-read \Illuminate\Database\Eloquent\Collection|Employee[] $employees
23
 * @property-read Planner $planner
24
 * @property-read Company $company
25
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereId($value)
26
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereCreatedAt($value)
27
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereUpdatedAt($value)
28
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereName($value)
29
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereDescription($value)
30
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereCompanyId($value)
31
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group wherePlannerId($value)
32
 */
33
class Group extends Model
34
{
35
    /**
36
     * The database table used by the model.
37
     *
38
     * @var string
39
     */
40
    protected $table = 'groups';
41
42
    /**
43
     * The attributes that are mass assignable.
44
     *
45
     * @var array
46
     */
47
    protected $fillable = ['name', 'description', 'planner_id'];
48
49
    /**
50
     * @var array
51
     */
52
    protected $hidden = ['planner', 'pivot'];
53
54
    /**
55
     * @var array
56
     */
57
    protected $appends = ['planner_name'];
58
59 20
    public function getPlannerNameAttribute()
60
    {
61 20
        if(is_object($this->planner) && $this->planner->exists)
62 20
            return $this->planner->name;
63
        return null;
64
    }
65
66
    /**
67
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
68
     */
69 10
    public function employees()
70
    {
71 10
        return $this->belongsToMany(Employee::class);
72
    }
73
74
    /**
75
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
76
     */
77 22
    public function planner()
78
    {
79 22
        return $this->belongsTo(Planner::class);
80
    }
81
82
    /**
83
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
84
     */
85
    public function company()
86
    {
87
        return $this->belongsTo(Company::class);
88
    }
89
}
90