first(); if (! $record) { $record = new InvoiceDesign(); $record->id = $i + 1; $record->name = $design; } $record->pdfmake = $pdfmake; $record->save(); } } } for ($i = 1; $i <= 3; $i++) { $name = 'Custom' . $i; $id = $i + 10; if (InvoiceDesign::whereName($name)->orWhere('id', '=', $id)->first()) { continue; } InvoiceDesign::create([ 'id' => $id, 'name' => $name, ]); } } }