Completed
Push — master ( f2f6fa...1beb9c )
by claudio
03:43
created

Employee::groups()   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 2
Bugs 0 Features 0
Metric Value
c 2
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
use Illuminate\Auth\Authenticatable;
7
use Illuminate\Auth\Passwords\CanResetPassword;
8
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
9
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
10
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
11
use Illuminate\Database\Eloquent\SoftDeletes;
12
use Illuminate\Foundation\Auth\Access\Authorizable;
13
14
/**
15
 * plunner\Employee
16
 *
17
 * @property integer $id
18
 * @property string $name
19
 * @property string $email
20
 * @property string $password
21
 * @property integer $company_id
22
 * @property string $remember_token
23
 * @property \Carbon\Carbon $created_at
24
 * @property \Carbon\Carbon $updated_at
25
 * @property-read \plunner\Company $company
26
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups
27
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereId($value)
28
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereName($value)
29
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereEmail($value)
30
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee wherePassword($value)
31
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereCompanyId($value)
32
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereRememberToken($value)
33
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereCreatedAt($value)
34
 * @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereUpdatedAt($value)
35
 */
36
class Employee extends Model implements AuthenticatableContract,
37
                                        AuthorizableContract,
38
                                        CanResetPasswordContract
39
{
40
    use Authenticatable, Authorizable, CanResetPassword;
41
42
    /**
43
     * The database table used by the model.
44
     *
45
     * @var string
46
     */
47
    //protected $table = 'employees';
48
49
    /**
50
     * The attributes that are mass assignable.
51
     *
52
     * @var array
53
     */
54
    protected $fillable = ['name', 'email', 'password'];
55
56
    /**
57
     * The attributes excluded from the model's JSON form.
58
     *
59
     * @var array
60
     */
61
    protected $hidden = ['password', 'remember_token'];
62
63 1
    public function company()
64
    {
65 1
        return $this->belongsTo('plunner\Company');
66
    }
67
68
    public function groups()
69
    {
70
        return $this->belongsToMany('plunner\Group', 'employee_groups');
71
    }
72
73
    public function meetings()
74
    {
75
        return $this->belongsToMany('plunner\Meeting');
76
    }
77
78
    /**
79
     * Get the e-mail address where password reset links are sent.
80
     *
81
     * Make email unique
82
     *
83
     * @return string
84
     */
85 1
    public function getEmailForPasswordReset()
86
    {
87 1
        return $this->email.$this->company->id;
88
    }
89
}
90