mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve check data account id checks
This commit is contained in:
parent
f71adbc388
commit
9cfdfe3099
@ -2,6 +2,7 @@
|
||||
|
||||
use DB;
|
||||
use Mail;
|
||||
use Utils;
|
||||
use Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -142,20 +143,26 @@ class CheckData extends Command {
|
||||
ENTITY_VENDOR,
|
||||
ENTITY_INVOICE,
|
||||
ENTITY_USER
|
||||
],
|
||||
'products' => [
|
||||
ENTITY_USER,
|
||||
],
|
||||
'expense_categories' => [
|
||||
ENTITY_USER,
|
||||
],
|
||||
'projects' => [
|
||||
ENTITY_USER,
|
||||
ENTITY_CLIENT,
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($tables as $table => $entityTypes) {
|
||||
foreach ($entityTypes as $entityType) {
|
||||
$tableName = Utils::pluralizeEntityType($entityType);
|
||||
$records = DB::table($table)
|
||||
->join("{$entityType}s", "{$entityType}s.id", '=', "{$table}.{$entityType}_id");
|
||||
|
||||
if ($entityType != ENTITY_CLIENT) {
|
||||
$records = $records->join('clients', 'clients.id', '=', "{$table}.client_id");
|
||||
}
|
||||
|
||||
$records = $records->where("{$table}.account_id", '!=', DB::raw("{$entityType}s.account_id"))
|
||||
->get(["{$table}.id", 'clients.account_id', 'clients.user_id']);
|
||||
->join($tableName, "{$tableName}.id", '=', "{$table}.{$entityType}_id")
|
||||
->where("{$table}.account_id", '!=', DB::raw("{$tableName}.account_id"))
|
||||
->get(["{$table}.id"]);
|
||||
|
||||
if (count($records)) {
|
||||
$this->isValid = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user