Completed
Push — master ( 2c87a7...c05784 )
by claudio
04:06
created

Company::verifyCompany()   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 1
crap 2
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 34
    public function employees()
68
    {
69 34
        return $this->hasMany(Employee::class);
70
    }
71
72 14
    public function groups()
73
    {
74 14
        return $this->hasMany(Group::class);
75
    }
76
77
    /**
78
     * @param Group $group
79
     * @return bool
80
     */
81 10
    public function verifyGroup(Group $group)
82
    {
83 10
        return $group->company_id === $this->id;
84
    }
85
86
    /**
87
     * @param Employee $employee
88
     * @return bool
89
     */
90 8
    public function verifyEmployee(Employee $employee)
91
    {
92 8
        return $employee->company_id === $this->id;
93
    }
94
95
    /**
96
     * @param Company $company
97
     * @return bool
98
     */
99
    public function verifyCompany(Company $company)
100
    {
101
        return $company->id === $this->id;
102
    }
103
}
104