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 DB;
|
||||||
use Mail;
|
use Mail;
|
||||||
|
use Utils;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@ -142,20 +143,26 @@ class CheckData extends Command {
|
|||||||
ENTITY_VENDOR,
|
ENTITY_VENDOR,
|
||||||
ENTITY_INVOICE,
|
ENTITY_INVOICE,
|
||||||
ENTITY_USER
|
ENTITY_USER
|
||||||
|
],
|
||||||
|
'products' => [
|
||||||
|
ENTITY_USER,
|
||||||
|
],
|
||||||
|
'expense_categories' => [
|
||||||
|
ENTITY_USER,
|
||||||
|
],
|
||||||
|
'projects' => [
|
||||||
|
ENTITY_USER,
|
||||||
|
ENTITY_CLIENT,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($tables as $table => $entityTypes) {
|
foreach ($tables as $table => $entityTypes) {
|
||||||
foreach ($entityTypes as $entityType) {
|
foreach ($entityTypes as $entityType) {
|
||||||
|
$tableName = Utils::pluralizeEntityType($entityType);
|
||||||
$records = DB::table($table)
|
$records = DB::table($table)
|
||||||
->join("{$entityType}s", "{$entityType}s.id", '=', "{$table}.{$entityType}_id");
|
->join($tableName, "{$tableName}.id", '=', "{$table}.{$entityType}_id")
|
||||||
|
->where("{$table}.account_id", '!=', DB::raw("{$tableName}.account_id"))
|
||||||
if ($entityType != ENTITY_CLIENT) {
|
->get(["{$table}.id"]);
|
||||||
$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']);
|
|
||||||
|
|
||||||
if (count($records)) {
|
if (count($records)) {
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user