1 | <?php |
||
66 | class Tenant extends Model |
||
67 | { |
||
68 | use HasSlug; |
||
69 | use HasTranslations; |
||
70 | use ValidatingTrait; |
||
71 | use CacheableEloquent; |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | protected $fillable = [ |
||
77 | 'slug', |
||
78 | 'name', |
||
79 | 'description', |
||
80 | 'user_id', |
||
81 | 'user_type', |
||
82 | 'email', |
||
83 | 'website', |
||
84 | 'phone', |
||
85 | 'language_code', |
||
86 | 'country_code', |
||
87 | 'state', |
||
88 | 'city', |
||
89 | 'address', |
||
90 | 'postal_code', |
||
91 | 'launch_date', |
||
92 | 'group', |
||
93 | 'is_active', |
||
94 | ]; |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | protected $casts = [ |
||
100 | 'slug' => 'string', |
||
101 | 'user_id' => 'integer', |
||
102 | 'user_type' => 'string', |
||
103 | 'email' => 'string', |
||
104 | 'website' => 'string', |
||
105 | 'phone' => 'string', |
||
106 | 'country_code' => 'string', |
||
107 | 'language_code' => 'string', |
||
108 | 'state' => 'string', |
||
109 | 'city' => 'string', |
||
110 | 'address' => 'string', |
||
111 | 'postal_code' => 'string', |
||
112 | 'launch_date' => 'string', |
||
113 | 'group' => 'string', |
||
114 | 'is_active' => 'boolean', |
||
115 | 'deleted_at' => 'datetime', |
||
116 | ]; |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | protected $observables = [ |
||
122 | 'validating', |
||
123 | 'validated', |
||
124 | ]; |
||
125 | |||
126 | /** |
||
127 | * The attributes that are translatable. |
||
128 | * |
||
129 | * @var array |
||
130 | */ |
||
131 | public $translatable = [ |
||
132 | 'name', |
||
133 | 'description', |
||
134 | ]; |
||
135 | |||
136 | /** |
||
137 | * The default rules that the model will validate against. |
||
138 | * |
||
139 | * @var array |
||
140 | */ |
||
141 | protected $rules = []; |
||
142 | |||
143 | /** |
||
144 | * Whether the model should throw a |
||
145 | * ValidationException if it fails validation. |
||
146 | * |
||
147 | * @var bool |
||
148 | */ |
||
149 | protected $throwValidationExceptions = true; |
||
150 | |||
151 | /** |
||
152 | * Create a new Eloquent model instance. |
||
153 | * |
||
154 | * @param array $attributes |
||
155 | */ |
||
156 | public function __construct(array $attributes = []) |
||
181 | |||
182 | /** |
||
183 | * Get all attached models of the given class to the tenant. |
||
184 | * |
||
185 | * @param string $class |
||
186 | * |
||
187 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
188 | */ |
||
189 | public function entries(string $class): MorphToMany |
||
193 | |||
194 | /** |
||
195 | * Get the options for generating the slug. |
||
196 | * |
||
197 | * @return \Spatie\Sluggable\SlugOptions |
||
198 | */ |
||
199 | public function getSlugOptions(): SlugOptions |
||
206 | |||
207 | /** |
||
208 | * Get the owning user. |
||
209 | * |
||
210 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
211 | */ |
||
212 | public function user(): MorphTo |
||
216 | |||
217 | /** |
||
218 | * Get bookings of the given user. |
||
219 | * |
||
220 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
221 | * @param \Illuminate\Database\Eloquent\Model $user |
||
222 | * |
||
223 | * @return \Illuminate\Database\Eloquent\Builder |
||
224 | */ |
||
225 | public function scopeOfUser(Builder $builder, Model $user): Builder |
||
229 | |||
230 | /** |
||
231 | * Activate the tenant. |
||
232 | * |
||
233 | * @return $this |
||
234 | */ |
||
235 | public function activate() |
||
241 | |||
242 | /** |
||
243 | * Deactivate the tenant. |
||
244 | * |
||
245 | * @return $this |
||
246 | */ |
||
247 | public function deactivate() |
||
253 | } |
||
254 |
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.