'required|min_length[2]|max_length[100]', 'price' => 'required|numeric|greater_than_equal[0]', 'max_users' => 'required|integer|greater_than[0]', 'max_clients' => 'required|integer|greater_than[0]', 'max_storage' => 'required|integer|greater_than[0]', ]; protected $validationMessages = [ 'name' => [ 'required' => 'Название тарифа обязательно', 'min_length' => 'Название должно быть минимум 2 символа', ], 'price' => [ 'required' => 'Цена обязательна', 'numeric' => 'Цена должна быть числом', ], ]; /** * Получение активных тарифов */ public function getActivePlans() { return $this->where('is_active', 1)->findAll(); } /** * Получение тарифа по умолчанию */ public function getDefaultPlan() { return $this->where('is_default', 1)->where('is_active', 1)->first(); } /** * Проверка, является ли тариф системным */ public function isSystemPlan($planId) { $plan = $this->find($planId); return $plan !== null; } }