Completed
Push — master ( 4b2855...383ea8 )
by claudio
04:18
created

Company::employees()   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\Auth\Authenticatable;
6
use Illuminate\Auth\Passwords\CanResetPassword;
7
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
8
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
9
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
10
use Illuminate\Database\Eloquent\Model;
11
use Illuminate\Foundation\Auth\Access\Authorizable;
12
13
/**
14
 * plunner\Company
15
 *
16
 * @property integer $id
17
 * @property string $name
18
 * @property string $email
19
 * @property string $password
20
 * @property string $remember_token
21
 * @property \Carbon\Carbon $created_at
22
 * @property \Carbon\Carbon $updated_at
23
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereId($value)
24
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereName($value)
25
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereEmail($value)
26
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company wherePassword($value)
27
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereRememberToken($value)
28
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereCreatedAt($value)
29
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereUpdatedAt($value)
30
 * @property string $deleted_at
31
 * @property boolean $verified
32
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereDeletedAt($value)
33
 * @method static \Illuminate\Database\Query\Builder|\plunner\Company whereVerified($value)
34
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Employee[] $employees
35
 */
36
class Company extends Model implements AuthenticatableContract,
37
                                    AuthorizableContract,
38
                                    CanResetPasswordContract,
39
                                    PolicyCheckable
40
{
41
    use Authenticatable, Authorizable, CanResetPassword;
42
43
    /**
44
     * The database table used by the model.
45
     *
46
     * @var string
47
     */
48
    //protected $table = 'users';
49
50
    /**
51
     * The attributes that are mass assignable.
52
     *
53
     * @var array
54
     */
55
    protected $fillable = ['name', 'email', 'password'];
56
57
    /**
58
     * The attributes excluded from the model's JSON form.
59
     *
60
     * @var array
61
     */
62
    protected $hidden = ['password', 'remember_token'];
63
64
    /**
65
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
66
     */
67 12
    public function employees()
68
    {
69 12
        return $this->hasMany('plunner\Employee');
70
    }
71
72
    /**
73
     * @param Group $group
74
     * @return bool
75
     */
76
    public function verifyGroup(Group $group)
77
    {
78
        return $group->company_id === $this->id;
79
    }
80
81
    /**
82
     * @param Employee $employee
83
     * @return bool
84
     */
85 8
    public function verifyEmployee(Employee $employee)
86
    {
87 8
        return $employee->company_id === $this->id;
88
    }
89
90
    /**
91
     * @param Company $company
92
     * @return bool
93
     */
94
    public function verifyCompany(Company $company)
95
    {
96
        return $company->id === $this->id;
97
    }
98
}
99