Skip to content

Commit

Permalink
Adiciona cids com insert
Browse files Browse the repository at this point in the history
  • Loading branch information
a21ns1g4ts committed Jan 31, 2021
1 parent 2ceedbc commit 82a7166
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 53 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
* Repositórios DB e FILE
* Integração Contínua
* Política de consumo da api

## [1.0.1] - 31/01/2021

### Melhorias

* Semea cids com insert
12 changes: 1 addition & 11 deletions database/migrations/2019_01_09_014149_create_cid10_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

class CreateCid10Table extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cid10', function (Blueprint $table) {
Expand All @@ -19,12 +14,7 @@ public function up()
$table->string('nome' , 254);
});
}

/**
* Reverse the migrations.
*
* @return void
*/

public function down()
{
Schema::dropIfExists('cid10');
Expand Down
17 changes: 0 additions & 17 deletions database/migrations/2019_10_17_014149_create_visitors_table.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
<?php
/**
* Created by Atila Silva.
* Date: sáb, ou 2021 21:59:31 +0000.
*/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
* Class CreateVisitorsTable
*/
class CreateVisitorsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('visitors', function (Blueprint $table) {
Expand All @@ -28,11 +16,6 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('visitors');
Expand Down
7 changes: 1 addition & 6 deletions database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call('cid10TableSeeder');
$this->call(cid10TableSeeder::class);
}
}
27 changes: 8 additions & 19 deletions database/seeds/cid10TableSeeder.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
<?php

use App\Cid10;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class cid10TableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$cids = json_decode(file_get_contents(__DIR__ . '/cid10.json'));
$cids = (array) json_decode(file_get_contents(__DIR__ . '/cid10.json'));

$inserts = [];

if (env('APP_ENV') === 'test'){
DB::table('cid10')->insert([
'nome' =>$cids[0]->nome,
'codigo' => $cids[0]->codigo
]);
}else{
foreach ($cids as $cid){
DB::table('cid10')->insert([
'nome' =>$cid->nome,
'codigo' => $cid->codigo
]);
}
foreach ($cids as $cid){
array_push($inserts, (array) $cid);
}

Cid10::insert($inserts);
}
}

0 comments on commit 82a7166

Please sign in to comment.