Completed
Pull Request — master (#28)
by claudio
07:42 queued 01:16
created

Group::meetings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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
 * @property-read \Illuminate\Database\Eloquent\Collection|Meeting[] $meetings
33
 */
34
class Group extends Model
35
{
36
    /**
37
     * The attributes that are mass assignable.
38
     *
39
     * @var array
40
     */
41
    protected $fillable = ['name', 'description', 'planner_id'];
42
43
    /**
44
     * @var array
45
     */
46
    protected $hidden = ['planner', 'pivot'];
47
48
    /**
49
     * @var array
50
     */
51
    protected $appends = ['planner_name'];
52
53 28
    public function getPlannerNameAttribute()
54
    {
55 28
        if(is_object($this->planner) && $this->planner->exists)
56 28
            return $this->planner->name;
57
        return null;
58
    }
59
60
    /**
61
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
62
     */
63 16
    public function employees()
64
    {
65 16
        return $this->belongsToMany(Employee::class);
66
    }
67
68
    /**
69
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
70
     */
71 34
    public function planner()
72
    {
73 34
        return $this->belongsTo(Planner::class);
74
    }
75
76
    /**
77
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
78
     */
79
    public function company()
80
    {
81
        return $this->belongsTo(Company::class);
82
    }
83
84 2
    public function meetings()
85
    {
86 2
        return $this->hasMany(Meeting::class);
87
    }
88
}
89