first(); if (($input['start'] <= $input['end']) && (srtlen($input['start']) == srtlen($input['end']))) { for ($i = $input['start']; $i <= $input['end']; $i++) { $total = Client::where('name', '=', $i)->count(); $client = new Client; if ($total >= 1) { $total = $total + 1; $client->name = '#' . $total . ' ' . urldecode($i); } else { $client->name = urldecode($i); } $client->user_code = strtoupper(md5(time() + $i)); $client->group_id = $group['code']; $client->is_special_price = 0; $barcode = new ClientsBarcode; $barcode->code_id = $i; $barcode->name = ''; $barcode->client_guid = $client->user_code; $barcode->value = $i; $barcode->block = 0; $barcode->symptom_block = 0; $barcode->save(); $client->save(); } return [ 'status' => 'success', 'message' => 'Штрих коды созданы', ]; } else { return [ 'status' => 'error', 'message' => 'Проверьте правильность введенных данных', ]; } } }