Merge pull request #1767 from burakcakirel/remove-pluck-from-update-script
Remove pluck method from update script
This commit is contained in:
commit
2a3a2c5bb6
@ -129,16 +129,18 @@ class Version210 extends Listener
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
$documentId = DB::table('documents')
|
$document = DB::table('documents')
|
||||||
->where('document_number', $invoice->invoice_number)
|
->where('document_number', $invoice->invoice_number)
|
||||||
->where('deleted_at', $invoice->deleted_at)
|
->where('deleted_at', $invoice->deleted_at)
|
||||||
->where('company_id', $invoice->company_id)
|
->where('company_id', $invoice->company_id)
|
||||||
->where('type', Document::INVOICE_TYPE)
|
->where('type', Document::INVOICE_TYPE)
|
||||||
->pluck('id')
|
->first('id');
|
||||||
->first();
|
|
||||||
|
|
||||||
|
if ($document) {
|
||||||
DB::table('credits_transactions')
|
DB::table('credits_transactions')
|
||||||
->where('id', $invoice->credits_transactions_id)->update(['document_id' => $documentId]);
|
->where('id', $invoice->credits_transactions_id)
|
||||||
|
->update(['document_id' => $document->id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$credit_notes = DB::table('credits_transactions')
|
$credit_notes = DB::table('credits_transactions')
|
||||||
@ -154,16 +156,18 @@ class Version210 extends Listener
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($credit_notes as $credit_note) {
|
foreach ($credit_notes as $credit_note) {
|
||||||
$documentId = DB::table('documents')
|
$document = DB::table('documents')
|
||||||
->where('document_number', $credit_note->credit_note_number)
|
->where('document_number', $credit_note->credit_note_number)
|
||||||
->where('deleted_at', $credit_note->deleted_at)
|
->where('deleted_at', $credit_note->deleted_at)
|
||||||
->where('company_id', $credit_note->company_id)
|
->where('company_id', $credit_note->company_id)
|
||||||
->where('type', self::CREDIT_NOTE_TYPE)
|
->where('type', self::CREDIT_NOTE_TYPE)
|
||||||
->pluck('id')
|
->first('id');
|
||||||
->first();
|
|
||||||
|
|
||||||
|
if ($document) {
|
||||||
DB::table('credits_transactions')
|
DB::table('credits_transactions')
|
||||||
->where('id', $credit_note->credits_transactions_id)->update(['document_id' => $documentId]);
|
->where('id', $credit_note->credits_transactions_id)
|
||||||
|
->update(['document_id' => $document->id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,15 +239,17 @@ class Version210 extends Listener
|
|||||||
$builder->delete();
|
$builder->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$documentType = DB::table($new_table)->orderBy('id')->pluck('type')->first();
|
|
||||||
|
|
||||||
// To be able to update TYPE_id relations
|
// To be able to update TYPE_id relations
|
||||||
$this->addDocumentIdForeignKeys($documentType);
|
$document = DB::table($new_table)->orderBy('id')->first('type');
|
||||||
|
if ($document) {
|
||||||
|
$this->addDocumentIdForeignKeys($document->type);
|
||||||
|
}
|
||||||
|
|
||||||
// Update relation ids
|
// Update relation ids
|
||||||
DB::table($new_table)
|
$document = DB::table($table)->orderByDesc('id')->first('id');
|
||||||
->orderByDesc('id')
|
if ($document) {
|
||||||
->increment('id', DB::table($table)->orderByDesc('id')->pluck('id')->first());
|
DB::table($new_table)->orderByDesc('id')->increment('id', $document->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertColumns = collect(Schema::getColumnListing($new_table));
|
$insertColumns = collect(Schema::getColumnListing($new_table));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user