1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Add check for duplicate id in design seeder

This commit is contained in:
Hillel Coren 2017-06-19 10:46:55 +03:00
parent 7696ba610c
commit a6aa59ac2f

View File

@ -41,12 +41,16 @@ class InvoiceDesignsSeeder extends Seeder
for ($i = 1; $i <= 3; $i++) {
$name = 'Custom' . $i;
if (! InvoiceDesign::whereName($name)->first()) {
InvoiceDesign::create([
'id' => $i + 10,
'name' => $name,
]);
$id = $i + 10;
if (InvoiceDesign::whereName($name)->orWhere('id', '=', $id)->first()) {
continue;
}
InvoiceDesign::create([
'id' => $id,
'name' => $name,
]);
}
}
}