1 | <?php |
||
65 | class Tenant extends Model |
||
66 | { |
||
67 | use HasSlug; |
||
68 | use HasTranslations; |
||
69 | use ValidatingTrait; |
||
70 | use CacheableEloquent; |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | protected $fillable = [ |
||
76 | 'slug', |
||
77 | 'name', |
||
78 | 'description', |
||
79 | 'email', |
||
80 | 'website', |
||
81 | 'phone', |
||
82 | 'language_code', |
||
83 | 'country_code', |
||
84 | 'state', |
||
85 | 'city', |
||
86 | 'address', |
||
87 | 'postal_code', |
||
88 | 'launch_date', |
||
89 | 'timezone', |
||
90 | 'currency', |
||
91 | 'is_active', |
||
92 | ]; |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | protected $casts = [ |
||
98 | 'slug' => 'string', |
||
99 | 'email' => 'string', |
||
100 | 'website' => 'string', |
||
101 | 'phone' => 'string', |
||
102 | 'country_code' => 'string', |
||
103 | 'language_code' => 'string', |
||
104 | 'state' => 'string', |
||
105 | 'city' => 'string', |
||
106 | 'address' => 'string', |
||
107 | 'postal_code' => 'string', |
||
108 | 'launch_date' => 'string', |
||
109 | 'timezone' => 'string', |
||
110 | 'currency' => 'string', |
||
111 | 'is_active' => 'boolean', |
||
112 | 'deleted_at' => 'datetime', |
||
113 | ]; |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | protected $observables = [ |
||
119 | 'validating', |
||
120 | 'validated', |
||
121 | ]; |
||
122 | |||
123 | /** |
||
124 | * The attributes that are translatable. |
||
125 | * |
||
126 | * @var array |
||
127 | */ |
||
128 | public $translatable = [ |
||
129 | 'name', |
||
130 | 'description', |
||
131 | ]; |
||
132 | |||
133 | /** |
||
134 | * The default rules that the model will validate against. |
||
135 | * |
||
136 | * @var array |
||
137 | */ |
||
138 | protected $rules = []; |
||
139 | |||
140 | /** |
||
141 | * Whether the model should throw a |
||
142 | * ValidationException if it fails validation. |
||
143 | * |
||
144 | * @var bool |
||
145 | */ |
||
146 | protected $throwValidationExceptions = true; |
||
147 | |||
148 | /** |
||
149 | * Create a new Eloquent model instance. |
||
150 | * |
||
151 | * @param array $attributes |
||
152 | */ |
||
153 | public function __construct(array $attributes = []) |
||
177 | |||
178 | /** |
||
179 | * Get all attached models of the given class to the tenant. |
||
180 | * |
||
181 | * @param string $class |
||
182 | * |
||
183 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
184 | */ |
||
185 | public function entries(string $class): MorphToMany |
||
189 | |||
190 | /** |
||
191 | * Get the options for generating the slug. |
||
192 | * |
||
193 | * @return \Spatie\Sluggable\SlugOptions |
||
194 | */ |
||
195 | public function getSlugOptions(): SlugOptions |
||
202 | |||
203 | /** |
||
204 | * Get the tenant's country. |
||
205 | * |
||
206 | * @return \Rinvex\Country\Country |
||
207 | */ |
||
208 | public function getCountryAttribute() |
||
212 | |||
213 | /** |
||
214 | * Get the tenant's language. |
||
215 | * |
||
216 | * @return \Rinvex\Language\Language |
||
217 | */ |
||
218 | public function getLanguageAttribute() |
||
222 | |||
223 | /** |
||
224 | * Determine if the given model is supermanager of the tenant. |
||
225 | * |
||
226 | * @param \Illuminate\Database\Eloquent\Model $model |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function isSuperManager(Model $model): bool |
||
234 | |||
235 | /** |
||
236 | * Determine if the given model is manager of the tenant. |
||
237 | * |
||
238 | * @param \Illuminate\Database\Eloquent\Model $model |
||
239 | * |
||
240 | * @return bool |
||
241 | */ |
||
242 | public function isManager(Model $model): bool |
||
246 | |||
247 | /** |
||
248 | * Activate the tenant. |
||
249 | * |
||
250 | * @return $this |
||
251 | */ |
||
252 | public function activate() |
||
258 | |||
259 | /** |
||
260 | * Deactivate the tenant. |
||
261 | * |
||
262 | * @return $this |
||
263 | */ |
||
264 | public function deactivate() |
||
270 | } |
||
271 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.