55namespace Laravelcm \Subscriptions \Models ;
66
77use Illuminate \Database \Eloquent \Model ;
8- use Rinvex \Support \Traits \ValidatingTrait ;
98use Illuminate \Database \Eloquent \SoftDeletes ;
109use Illuminate \Database \Eloquent \Relations \HasMany ;
1110use Illuminate \Database \Eloquent \Factories \HasFactory ;
12- use Rinvex \ Support \Traits \HasTranslations ;
13- use Rinvex \ Support \Traits \HasSlug ;
11+ use Laravelcm \ Subscriptions \Traits \HasSlug ;
12+ use Laravelcm \ Subscriptions \Traits \HasTranslations ;
1413use Spatie \EloquentSortable \SortableTrait ;
1514use Spatie \Sluggable \SlugOptions ;
1615use Spatie \EloquentSortable \Sortable ;
@@ -74,7 +73,6 @@ final class Plan extends Model implements Sortable
7473 use HasTranslations;
7574 use SoftDeletes;
7675 use SortableTrait;
77- use ValidatingTrait;
7876
7977 protected $ fillable = [
8078 'slug ' ,
@@ -117,11 +115,6 @@ final class Plan extends Model implements Sortable
117115 'deleted_at ' => 'datetime ' ,
118116 ];
119117
120- protected $ observables = [
121- 'validating ' ,
122- 'validated ' ,
123- ];
124-
125118 /**
126119 * The attributes that are translatable.
127120 *
@@ -132,55 +125,13 @@ final class Plan extends Model implements Sortable
132125 'description ' ,
133126 ];
134127
135- /**
136- * The sortable settings.
137- *
138- * @var array
139- */
140- public $ sortable = [
128+ public array $ sortable = [
141129 'order_column_name ' => 'sort_order ' ,
142130 ];
143131
144- /**
145- * The default rules that the model will validate against.
146- *
147- * @var array
148- */
149- protected $ rules = [];
150-
151- /**
152- * Whether the model should throw a
153- * ValidationException if it fails validation.
154- *
155- * @var bool
156- */
157- protected $ throwValidationExceptions = true ;
158-
159- public function __construct (array $ attributes = [])
132+ public function getTable (): string
160133 {
161- $ this ->setTable (config ('laravel-subscriptions.tables.plans ' ));
162- $ this ->mergeRules ([
163- 'slug ' => 'required|alpha_dash|max:150|unique: ' .config ('laravel-subscriptions.tables.plans ' ).',slug ' ,
164- 'name ' => 'required|string|strip_tags|max:150 ' ,
165- 'description ' => 'nullable|string|max:32768 ' ,
166- 'is_active ' => 'sometimes|boolean ' ,
167- 'price ' => 'required|numeric ' ,
168- 'signup_fee ' => 'required|numeric ' ,
169- 'currency ' => 'required|alpha|size:3 ' ,
170- 'trial_period ' => 'sometimes|integer|max:100000 ' ,
171- 'trial_interval ' => 'sometimes|in:hour,day,week,month ' ,
172- 'invoice_period ' => 'sometimes|integer|max:100000 ' ,
173- 'invoice_interval ' => 'sometimes|in:hour,day,week,month ' ,
174- 'grace_period ' => 'sometimes|integer|max:100000 ' ,
175- 'grace_interval ' => 'sometimes|in:hour,day,week,month ' ,
176- 'sort_order ' => 'nullable|integer|max:100000 ' ,
177- 'prorate_day ' => 'nullable|integer|max:150 ' ,
178- 'prorate_period ' => 'nullable|integer|max:150 ' ,
179- 'prorate_extend_due ' => 'nullable|integer|max:150 ' ,
180- 'active_subscribers_limit ' => 'nullable|integer|max:100000 ' ,
181- ]);
182-
183- parent ::__construct ($ attributes );
134+ return config ('laravel-subscriptions.tables.plans ' );
184135 }
185136
186137 protected static function boot (): void
@@ -226,13 +177,6 @@ public function hasGrace(): bool
226177 return $ this ->grace_period && $ this ->grace_interval ;
227178 }
228179
229- /**
230- * Get plan feature by the given slug.
231- *
232- * @param string $featureSlug
233- *
234- * @return \Laravelcm\Subscriptions\Models\Feature|null
235- */
236180 public function getFeatureBySlug (string $ featureSlug ): ?Feature
237181 {
238182 return $ this ->features ()->where ('slug ' , $ featureSlug )->first ();
0 commit comments