1 | <?php |
||
65 | class Tenant extends Model implements TenantContract |
||
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 | 'owner_id', |
||
80 | 'email', |
||
81 | 'website', |
||
82 | 'phone', |
||
83 | 'language_code', |
||
84 | 'country_code', |
||
85 | 'state', |
||
86 | 'city', |
||
87 | 'address', |
||
88 | 'postal_code', |
||
89 | 'launch_date', |
||
90 | 'group', |
||
91 | 'is_active', |
||
92 | 'thumbnail', |
||
93 | 'cover_photo', |
||
94 | ]; |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | protected $casts = [ |
||
100 | 'slug' => 'string', |
||
101 | 'owner_id' => 'integer', |
||
102 | 'email' => 'string', |
||
103 | 'website' => 'string', |
||
104 | 'phone' => 'string', |
||
105 | 'country_code' => 'string', |
||
106 | 'language_code' => 'string', |
||
107 | 'state' => 'string', |
||
108 | 'city' => 'string', |
||
109 | 'address' => 'string', |
||
110 | 'postal_code' => 'string', |
||
111 | 'launch_date' => 'string', |
||
112 | 'group' => 'string', |
||
113 | 'is_active' => 'boolean', |
||
114 | 'thumbnail' => 'string', |
||
115 | 'cover_photo' => 'string', |
||
116 | 'deleted_at' => 'datetime', |
||
117 | ]; |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | protected $observables = [ |
||
123 | 'validating', |
||
124 | 'validated', |
||
125 | ]; |
||
126 | |||
127 | /** |
||
128 | * The attributes that are translatable. |
||
129 | * |
||
130 | * @var array |
||
131 | */ |
||
132 | public $translatable = [ |
||
133 | 'name', |
||
134 | 'description', |
||
135 | ]; |
||
136 | |||
137 | /** |
||
138 | * The default rules that the model will validate against. |
||
139 | * |
||
140 | * @var array |
||
141 | */ |
||
142 | protected $rules = []; |
||
143 | |||
144 | /** |
||
145 | * Whether the model should throw a |
||
146 | * ValidationException if it fails validation. |
||
147 | * |
||
148 | * @var bool |
||
149 | */ |
||
150 | protected $throwValidationExceptions = true; |
||
151 | |||
152 | /** |
||
153 | * Create a new Eloquent model instance. |
||
154 | * |
||
155 | * @param array $attributes |
||
156 | */ |
||
157 | public function __construct(array $attributes = []) |
||
186 | |||
187 | /** |
||
188 | * Get all attached models of the given class to the tenant. |
||
189 | * |
||
190 | * @param string $class |
||
191 | * |
||
192 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
193 | */ |
||
194 | public function entries(string $class): MorphToMany |
||
198 | |||
199 | /** |
||
200 | * Get the options for generating the slug. |
||
201 | * |
||
202 | * @return \Spatie\Sluggable\SlugOptions |
||
203 | */ |
||
204 | public function getSlugOptions(): SlugOptions |
||
211 | |||
212 | /** |
||
213 | * A tenant always belongs to an owner. |
||
214 | * |
||
215 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
216 | */ |
||
217 | public function owner() |
||
223 | |||
224 | /** |
||
225 | * Activate the tenant. |
||
226 | * |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function activate() |
||
235 | |||
236 | /** |
||
237 | * Deactivate the tenant. |
||
238 | * |
||
239 | * @return $this |
||
240 | */ |
||
241 | public function deactivate() |
||
247 | } |
||
248 |
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.