2020-03-10 23:20:09 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-03-10 23:20:09 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-03-10 23:20:09 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-03-10 23:20:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\ValidationRules\Company;
|
|
|
|
|
2022-02-01 00:03:51 +01:00
|
|
|
use App\Utils\Ninja;
|
2020-03-10 23:20:09 +01:00
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class ValidCompanyQuantity.
|
2020-03-10 23:20:09 +01:00
|
|
|
*/
|
|
|
|
class ValidCompanyQuantity implements Rule
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $attribute
|
|
|
|
* @param mixed $value
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function passes($attribute, $value)
|
|
|
|
{
|
2022-11-24 10:33:52 +01:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (Ninja::isSelfHost()) {
|
2022-02-01 00:03:51 +01:00
|
|
|
return auth()->user()->company()->account->companies->count() < 10;
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2022-02-01 00:03:51 +01:00
|
|
|
|
|
|
|
return auth()->user()->company()->account->companies->count() < auth()->user()->company()->account->hosted_company_count;
|
2020-03-10 23:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function message()
|
|
|
|
{
|
2021-01-24 12:48:09 +01:00
|
|
|
return ctrans('texts.company_limit_reached');
|
2020-03-10 23:20:09 +01:00
|
|
|
}
|
|
|
|
}
|