1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AtlassianConnectCore\Models; |
4
|
|
|
|
5
|
|
|
use Illuminate\Auth\Authenticatable; |
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
7
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Tenant |
11
|
|
|
* |
12
|
|
|
* @property string $id |
13
|
|
|
* @property string $addon_key |
14
|
|
|
* @property string $client_key |
15
|
|
|
* @property string $public_key |
16
|
|
|
* @property string $shared_secret |
17
|
|
|
* @property string $server_version |
18
|
|
|
* @property string $base_url |
19
|
|
|
* @property string $plugin_version |
20
|
|
|
* @property string $product_type |
21
|
|
|
* @property string $description |
22
|
|
|
* @property string $event_type |
23
|
|
|
* @property string $remember_token |
24
|
|
|
* @property bool $is_dummy |
25
|
|
|
* @property \Carbon\Carbon $deleted_at |
26
|
|
|
* @property \Carbon\Carbon $created_at |
27
|
|
|
* @property \Carbon\Carbon $updated_at |
28
|
|
|
* |
29
|
|
|
* @package AtlassianConnectCore\Models |
30
|
|
|
*/ |
31
|
|
|
class Tenant extends Model implements \Illuminate\Contracts\Auth\Authenticatable |
32
|
|
|
{ |
33
|
|
|
use Authenticatable, SoftDeletes; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The attributes that are mass assignable. |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $fillable = [ |
41
|
|
|
'addon_key', |
42
|
|
|
'client_key', |
43
|
|
|
'public_key', |
44
|
|
|
'shared_secret', |
45
|
|
|
'server_version', |
46
|
|
|
'plugin_version', |
47
|
|
|
'base_url', |
48
|
|
|
'product_type', |
49
|
|
|
'description', |
50
|
|
|
'event_type', |
51
|
|
|
'is_dummy' |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* The attributes that should be cast to native types. |
56
|
|
|
* |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
protected $casts = [ |
60
|
|
|
'is_dummy' => 'bool' |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* The model's attributes. |
65
|
|
|
* |
66
|
|
|
* @var array |
67
|
|
|
*/ |
68
|
|
|
protected $attributes = [ |
69
|
|
|
'is_dummy' => false |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Tenant constructor. |
74
|
|
|
*/ |
75
|
|
|
public function __construct() |
76
|
|
|
{ |
77
|
|
|
parent::__construct(); |
78
|
|
|
|
79
|
|
|
$this->setTable(config('plugin.tenant')); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Checks whether Tenant's product type is JIRA |
84
|
|
|
* |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
|
|
public function isJira() |
88
|
|
|
{ |
89
|
|
|
return $this->product_type === 'jira'; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Checks whether Tenant's product type is Confluence |
94
|
|
|
* |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
public function isConfluence() |
98
|
|
|
{ |
99
|
|
|
return $this->product_type === 'confluence'; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Checks whether Tenant's add-on is installed |
104
|
|
|
* |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
|
|
public function isInstalled() |
108
|
|
|
{ |
109
|
|
|
return !$this->isUninstalled(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Checks whether Tenant's add-on is uninstalled |
114
|
|
|
* |
115
|
|
|
* @return bool |
116
|
|
|
*/ |
117
|
|
|
public function isUninstalled() |
118
|
|
|
{ |
119
|
|
|
return $this->event_type === 'uninstalled'; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Checks whether Tenant's add-on is enabled |
124
|
|
|
* |
125
|
|
|
* @return bool |
126
|
|
|
*/ |
127
|
|
|
public function isEnabled() |
128
|
|
|
{ |
129
|
|
|
return $this->event_type === 'enabled'; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Checks whether Tenant's add-on is disabled |
134
|
|
|
* |
135
|
|
|
* @return bool |
136
|
|
|
*/ |
137
|
|
|
public function isDisabled() |
138
|
|
|
{ |
139
|
|
|
return $this->event_type === 'disabled'; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Checks whether Tenant is dummy |
144
|
|
|
* |
145
|
|
|
* @return bool |
146
|
|
|
*/ |
147
|
|
|
public function isDummy() |
148
|
|
|
{ |
149
|
|
|
return $this->is_dummy; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Checks whether tenant is safely deleted |
154
|
|
|
* |
155
|
|
|
* @return bool |
156
|
|
|
*/ |
157
|
|
|
public function isDeleted() |
158
|
|
|
{ |
159
|
|
|
return $this->deleted_at !== null; |
160
|
|
|
} |
161
|
|
|
} |