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
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. 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)
|
|
|
|
{
|
2023-02-22 07:37:16 +01:00
|
|
|
if (config('ninja.testvars.travis')) {
|
2023-02-20 22:11:01 +01:00
|
|
|
return true;
|
2023-02-22 07:37:16 +01:00
|
|
|
}
|
2023-02-20 22:11:01 +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
|
|
|
|
2023-02-20 10:00:10 +01:00
|
|
|
return auth()->user()->account->isPaid() && auth()->user()->company()->account->companies->count() < 10 ;
|
2020-03-10 23:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function message()
|
|
|
|
{
|
2022-11-28 04:16:46 +01:00
|
|
|
return ctrans('texts.company_limit_reached', ['limit' => Ninja::isSelfHost() ? 10 : auth()->user()->company()->account->hosted_company_count]);
|
2020-03-10 23:20:09 +01:00
|
|
|
}
|
|
|
|
}
|