2019-12-08 11:28:52 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-12-08 11:28:52 +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)
|
2019-12-08 11:28:52 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-12-08 11:28:52 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\ValidationRules;
|
|
|
|
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class ValidUserForCompany.
|
2019-12-08 11:28:52 +01:00
|
|
|
*/
|
|
|
|
class ValidUserForCompany implements Rule
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $attribute
|
|
|
|
* @param mixed $value
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function passes($attribute, $value)
|
|
|
|
{
|
2023-08-07 07:07:52 +02:00
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
|
|
|
|
return MultiDB::checkUserAndCompanyCoExist($value, $user->company()->company_key);
|
2019-12-08 11:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function message()
|
|
|
|
{
|
2021-01-24 12:48:09 +01:00
|
|
|
return ctrans('texts.user_not_associated_with_this_account');
|
2019-12-08 11:28:52 +01:00
|
|
|
}
|
|
|
|
}
|