Passed
Pull Request — master (#54)
by Rafael
05:35
created

UsersInvite   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 104
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 16 1
A getSource() 0 3 1
A afterCreate() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Gewaer\Models;
5
6
use Gewaer\Traits\SubscriptionPlanLimitTrait;
7
8
class UsersInvite extends AbstractModel
9
{
10
    use SubscriptionPlanLimitTrait;
11
12
    /**
13
     *
14
     * @var integer
15
     */
16
    public $id;
17
18
    /**
19
     *
20
     * @var string
21
     */
22
    public $invite_hash;
23
24
    /**
25
     *
26
     * @var integer
27
     */
28
    public $companies_id;
29
30
    /**
31
     *
32
     * @var integer
33
     */
34
    public $role_id;
35
36
    /**
37
     *
38
     * @var integer
39
     */
40
    public $app_id;
41
42
    /**
43
     *
44
     * @var string
45
     */
46
    public $email;
47
48
    /**
49
     *
50
     * @var integer
51
     */
52
    public $is_deleted;
53
54
    /**
55
     *
56
     * @var string
57
     */
58
    public $created_at;
59
60
    /**
61
     *
62
     * @var string
63
     */
64
    public $updated_at;
65
66
    /**
67
     * Subscription plan key
68
     */
69
    protected $subscriptionPlanLimitKey = 'users';
70
71
    /**
72
     * Initialize method for model.
73
     */
74 4
    public function initialize()
75
    {
76 4
        $this->setSource('users_invite');
77
78 4
        $this->belongsTo(
79 4
            'companies_id',
80 4
            'Gewaer\Models\Companies',
81 4
            'id',
82 4
            ['alias' => 'company']
83
        );
84
85 4
        $this->belongsTo(
86 4
            'apps_id',
87 4
            'Gewaer\Models\Apps',
88 4
            'id',
89 4
            ['alias' => 'app']
90
        );
91 4
    }
92
93
    /**
94
     * Returns table name mapped in the model.
95
     *
96
     * @return string
97
     */
98 4
    public function getSource(): string
99
    {
100 4
        return 'users_invite';
101
    }
102
103
    /**
104
     * What to do after the creation of a new users
105
     *  - Assign default role
106
     *
107
     * @return void
108
     */
109 4
    public function afterCreate()
110
    {
111 4
        $this->updateAppActivityLimit();
112 4
    }
113
}
114