Skip to content

Commit 82a7166

Browse files
committed
Adiciona cids com insert
1 parent 2ceedbc commit 82a7166

File tree

5 files changed

+16
-53
lines changed

5 files changed

+16
-53
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@
88
* Repositórios DB e FILE
99
* Integração Contínua
1010
* Política de consumo da api
11+
12+
## [1.0.1] - 31/01/2021
13+
14+
### Melhorias
15+
16+
* Semea cids com insert

database/migrations/2019_01_09_014149_create_cid10_table.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
class CreateCid10Table extends Migration
88
{
9-
/**
10-
* Run the migrations.
11-
*
12-
* @return void
13-
*/
149
public function up()
1510
{
1611
Schema::create('cid10', function (Blueprint $table) {
@@ -19,12 +14,7 @@ public function up()
1914
$table->string('nome' , 254);
2015
});
2116
}
22-
23-
/**
24-
* Reverse the migrations.
25-
*
26-
* @return void
27-
*/
17+
2818
public function down()
2919
{
3020
Schema::dropIfExists('cid10');

database/migrations/2019_10_17_014149_create_visitors_table.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
<?php
2-
/**
3-
* Created by Atila Silva.
4-
* Date: sáb, ou 2021 21:59:31 +0000.
5-
*/
62

73
use Illuminate\Support\Facades\Schema;
84
use Illuminate\Database\Schema\Blueprint;
95
use Illuminate\Database\Migrations\Migration;
106

11-
/**
12-
* Class CreateVisitorsTable
13-
*/
147
class CreateVisitorsTable extends Migration
158
{
16-
/**
17-
* Run the migrations.
18-
*
19-
* @return void
20-
*/
219
public function up()
2210
{
2311
Schema::create('visitors', function (Blueprint $table) {
@@ -28,11 +16,6 @@ public function up()
2816
});
2917
}
3018

31-
/**
32-
* Reverse the migrations.
33-
*
34-
* @return void
35-
*/
3619
public function down()
3720
{
3821
Schema::dropIfExists('visitors');

database/seeds/DatabaseSeeder.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44

55
class DatabaseSeeder extends Seeder
66
{
7-
/**
8-
* Run the database seeds.
9-
*
10-
* @return void
11-
*/
127
public function run()
138
{
14-
$this->call('cid10TableSeeder');
9+
$this->call(cid10TableSeeder::class);
1510
}
1611
}
Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
<?php
22

3+
use App\Cid10;
34
use Illuminate\Database\Seeder;
4-
use Illuminate\Support\Facades\DB;
55

66
class cid10TableSeeder extends Seeder
77
{
8-
/**
9-
* Run the database seeds.
10-
*
11-
* @return void
12-
*/
138
public function run()
149
{
15-
$cids = json_decode(file_get_contents(__DIR__ . '/cid10.json'));
10+
$cids = (array) json_decode(file_get_contents(__DIR__ . '/cid10.json'));
11+
12+
$inserts = [];
1613

17-
if (env('APP_ENV') === 'test'){
18-
DB::table('cid10')->insert([
19-
'nome' =>$cids[0]->nome,
20-
'codigo' => $cids[0]->codigo
21-
]);
22-
}else{
23-
foreach ($cids as $cid){
24-
DB::table('cid10')->insert([
25-
'nome' =>$cid->nome,
26-
'codigo' => $cid->codigo
27-
]);
28-
}
14+
foreach ($cids as $cid){
15+
array_push($inserts, (array) $cid);
2916
}
17+
18+
Cid10::insert($inserts);
3019
}
3120
}

0 commit comments

Comments
 (0)