Completed
Push — master ( bc4e81...14a953 )
by claudio
04:04
created

Calendar::employee()   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
Metric Value
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
 * Class Calendar
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 string $name
16
 * @property integer $employee_id
17
 * @property \Carbon\Carbon $created_at
18
 * @property \Carbon\Carbon $updated_at
19
 * @property-read \plunner\Employee $employees
20
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Timeslot[] $timeslots
21
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereId($value)
22
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereName($value)
23
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereEmployeeId($value)
24
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereCreatedAt($value)
25
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereUpdatedAt($value)
26
 * @property string $type
27
 * @property string $sync_errors
28
 * @property boolean $enabled
29
 * @property-read \plunner\Employee $employee
30
 * @property-read Caldav $Caldav
31
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereType($value)
32
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereSyncErrors($value)
33
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereEnabled($value)
34
 */
35
class Calendar extends Model
36
{
37
    /**
38
     * The attributes that are mass assignable.
39
     *
40
     * @var array
41
     */
42
    protected $fillable = ['name'];
43
44
    /**
45
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
46
     */
47
    public function employee()
48
    {
49
        return $this->belongsTo('plunner\Employee');
50
    }
51
52
    /**
53
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
54
     */
55
    public function timeslots()
56
    {
57
        return $this->hasMany('plunner\Timeslot');
58
    }
59
60
    /**
61
     * @return \Illuminate\Database\Eloquent\Relations\HasOne|null
62
     */
63 2
    public function Caldav()
64
    {
65 2
        if($this->type == 'caldav')
66 2
            return $this->hasOne(Caldav::class);
67
        return null;
68
    }
69
}
70