-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from UNICEF01/bug_alertas_travados#291
Mudanca do tipo do campo do NIS na tabela Pesquisa e Comando para cor…
- Loading branch information
Showing
3 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace BuscaAtivaEscolar\Console\Commands; | ||
|
||
use BuscaAtivaEscolar\CaseSteps\Alerta; | ||
use BuscaAtivaEscolar\CaseSteps\Pesquisa; | ||
use BuscaAtivaEscolar\Child; | ||
use function foo\func; | ||
use Illuminate\Console\Command; | ||
use Log; | ||
|
||
class FixErrorCasesInAlertStep extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'correcoes:casos_travados_etapa_alerta'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Corrigir erro dos casos que permanecem na etapa de Alerta e deveriam estar na etapa de Pesquisa, considerando a possibilidade de erros como falta de endereço e bairro (campos obrigatórios para aprovacao de um alerta)'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->comment("Iniciando correcoes"); | ||
$qtd_alerts = Child::where(['current_step_type' => 'BuscaAtivaEscolar\CaseSteps\Alerta', 'alert_status' => 'accepted'])->count(); | ||
$children = Child::where(['current_step_type' => 'BuscaAtivaEscolar\CaseSteps\Alerta', 'alert_status' => 'accepted'])->get(); | ||
foreach ($children as $child){ | ||
$alerta = Alerta::where('child_id', $child->id)->first(); | ||
$pesquisa = Pesquisa::where('child_id', $child->id)->first(); | ||
|
||
if( $alerta->nis == ""){ $alerta->nis = null; } | ||
|
||
$child->current_step_id = $pesquisa->id; | ||
$child->current_step_type = 'BuscaAtivaEscolar\CaseSteps\Pesquisa'; | ||
|
||
$pesquisa->setFields($alerta->toArray()); | ||
|
||
$alerta->save(); | ||
$pesquisa->save(); | ||
$child->save(); | ||
} | ||
$this->comment("Finalizando correcoes dos ".$qtd_alerts." alertas"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2019_09_05_102849_update_nis_etsp_case_pesquisa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class UpdateNisEtspCasePesquisa extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
\Schema::table('case_steps_pesquisa', function (Blueprint $table) { | ||
$table->string('nis'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
|
||
} | ||
} |