mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 12:11:08 -04:00
fix migration error
This commit is contained in:
@ -41,44 +41,54 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->addresses->map(function ($address) use ($newCustomer) {
|
if ($user->addresses()->exists()) {
|
||||||
if ($address) {
|
$user->addresses->map(function ($address) use ($newCustomer) {
|
||||||
$address->customer_id = $newCustomer->id;
|
if ($address) {
|
||||||
$address->user_id = null;
|
$address->customer_id = $newCustomer->id;
|
||||||
$address->save();
|
$address->user_id = null;
|
||||||
}
|
$address->save();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$user->expenses->map(function ($expense) use ($newCustomer) {
|
if ($user->expenses()->exists()) {
|
||||||
if ($expense) {
|
$user->expenses->map(function ($expense) use ($newCustomer) {
|
||||||
$expense->customer_id = $newCustomer->id;
|
if ($expense) {
|
||||||
$expense->user_id = null;
|
$expense->customer_id = $newCustomer->id;
|
||||||
$expense->save();
|
$expense->user_id = null;
|
||||||
}
|
$expense->save();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$user->estimates->map(function ($estimate) use ($newCustomer) {
|
if ($user->estimates()->exists()) {
|
||||||
if ($estimate) {
|
$user->estimates->map(function ($estimate) use ($newCustomer) {
|
||||||
$estimate->customer_id = $newCustomer->id;
|
if ($estimate) {
|
||||||
$estimate->user_id = null;
|
$estimate->customer_id = $newCustomer->id;
|
||||||
$estimate->save();
|
$estimate->user_id = null;
|
||||||
}
|
$estimate->save();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$user->invoices->map(function ($invoice) use ($newCustomer) {
|
if ($user->invoices()->exists()) {
|
||||||
if ($invoice) {
|
$user->invoices->map(function ($invoice) use ($newCustomer) {
|
||||||
$invoice->customer_id = $newCustomer->id;
|
if ($invoice) {
|
||||||
$invoice->user_id = null;
|
$invoice->customer_id = $newCustomer->id;
|
||||||
$invoice->save();
|
$invoice->user_id = null;
|
||||||
}
|
$invoice->save();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$user->payments->map(function ($payment) use ($newCustomer) {
|
if ($user->payments()->exists()) {
|
||||||
if ($payment) {
|
$user->payments->map(function ($payment) use ($newCustomer) {
|
||||||
$payment->customer_id = $newCustomer->id;
|
if ($payment) {
|
||||||
$payment->save();
|
$payment->customer_id = $newCustomer->id;
|
||||||
}
|
$payment->save();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class AddOwnerIdToCompaniesTable extends Migration
|
|||||||
|
|
||||||
$companies = Company::all();
|
$companies = Company::all();
|
||||||
|
|
||||||
if ($companies) {
|
if ($companies && $user) {
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
$company->owner_id = $user->id;
|
$company->owner_id = $user->id;
|
||||||
$company->slug = Str::slug($company->name);
|
$company->slug = Str::slug($company->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user