Completed
Push — master ( c05784...e50bf7 )
by claudio
04:02
created

Group::company()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace plunner;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * plunner\Group
9
 *
10
 * @property integer $id
11
 * @property \Carbon\Carbon $created_at
12
 * @property \Carbon\Carbon $updated_at
13
 * @property string $name
14
 * @property string $description
15
 * @property integer $planner_id
16
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Employee[] $employees
17
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereId($value)
18
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereCreatedAt($value)
19
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereUpdatedAt($value)
20
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereName($value)
21
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereDescription($value)
22
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group wherePlannerId($value)
23
 * @property integer $company_id
24
 * @method static \Illuminate\Database\Query\Builder|\plunner\Group whereCompanyId($value)
25
 */
26
class Group extends Model
27
{
28
    /**
29
     * The database table used by the model.
30
     *
31
     * @var string
32
     */
33
    protected $table = 'groups';
34
35
    /**
36
     * The attributes that are mass assignable.
37
     *
38
     * @var array
39
     */
40
    protected $fillable = ['name', 'description', 'planner_id'];
41
42
    /**
43
     * @var array
44
     */
45
//    protected $hidden = ['planner'];
46
47
    /**
48
     * @var array
49
     */
50
    protected $appends = ['planner_name'];
51
52 14
    public function getPlannerNameAttribute()
53
    {
54 14
        if(is_object($this->planner) && $this->planner->exists)
0 ignored issues
show
Bug introduced by
The property planner does not seem to exist. Did you mean planner_id?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
55 14
            return $this->planner->name;
0 ignored issues
show
Bug introduced by
The property planner does not seem to exist. Did you mean planner_id?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
56 1
    }
57
58
    /**
59
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
60
     */
61
    public function employees()
62
    {
63
        return $this->belongsToMany(Employee::class);
64
    }
65
66 14
    public function planner()
67
    {
68 14
        return $this->belongsTo(Planner::class);
69
    }
70
71
    public function company()
72
    {
73
        return $this->belongsTo(Company::class);
74
    }
75
}
76