Test Failed
Pull Request — master (#52)
by Rafael
05:00
created

UsersInvite::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 16
ccs 0
cts 14
cp 0
crap 2
rs 9.9
c 0
b 0
f 0
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
    public function initialize()
75
    {
76
        $this->setSource('users_invite');
77
78
        $this->belongsTo(
79
            'companies_id',
80
            'Gewaer\Models\Companies',
81
            'id',
82
            ['alias' => 'company']
83
        );
84
85
        $this->belongsTo(
86
            'apps_id',
87
            'Gewaer\Models\Apps',
88
            'id',
89
            ['alias' => 'app']
90
        );
91
    }
92
93
    /**
94
     * Returns table name mapped in the model.
95
     *
96
     * @return string
97
     */
98
    public function getSource(): string
99
    {
100
        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
    public function afterCreate()
110
    {
111
        $this->updateAppActivityLimit();
112
    }
113
}
114