Commit 576b5454 authored by Gabriel-31415's avatar Gabriel-31415
Browse files

refatoracao migrations

parent 19a258ed
......@@ -14,4 +14,8 @@ class CoordenadorComissao extends Model
return $this->hasMany('App\Evento', 'coordenadorId');
}
public function trabalho(){
return $this->hasMany('App\Trabalho');
}
}
......@@ -11,6 +11,7 @@ use App\Atribuicao;
use App\Modalidade;
use App\ComissaoEvento;
use App\User;
use App\Proponente;
use App\Trabalho;
use App\AreaModalidade;
use App\CoordenadorComissao;
......@@ -170,19 +171,30 @@ class EventoController extends Controller
public function show($id)
{
$evento = Evento::find($id);
$hasTrabalho = false;
$hasTrabalhoCoautor = false;
$hasFile = false;
$trabalhos = Trabalho::where('proponente_id', Auth::user()->id)->get();
$trabalhosCount = Trabalho::where('proponente_id', Auth::user()->id)->count();
$proponente = Proponente::where('user_id', Auth::user()->id)->first();
if($proponente = null){
$hasTrabalho = false;
$hasFile = false;
$trabalhos = $proponente->trabalhos()->get();
$trabalhosCount = $proponente->trabalhos()->count();
if($trabalhosCount != 0){
$hasTrabalho = true;
$hasFile = true;
}
}else{
$hasTrabalho = false;
$hasFile = false;
$trabalhos = 0;
$trabalhosCount = 0;
}
$trabalhosId = Trabalho::where('evento_id', $evento->id)->select('id')->get();
//$trabalhosIdCoautor = Proponente::whereIn('trabalhoId', $trabalhosId)->where('proponente_id', Auth::user()->id)->select('trabalhoId')->get();
//$coautorCount = Coautor::whereIn('trabalhoId', $trabalhosId)->where('proponente_id', Auth::user()->id)->count();
//$trabalhosCoautor = Trabalho::whereIn('id', $trabalhosIdCoautor)->get();
if($trabalhosCount != 0){
$hasTrabalho = true;
$hasFile = true;
}
// if($coautorCount != 0){
// $hasTrabalhoCoautor = true;
// $hasFile = true;
......
......@@ -5,7 +5,9 @@ namespace App\Http\Controllers;
use App\Trabalho;
use App\Coautor;
use App\Evento;
use App\CoordenadorComissao;
use App\User;
use App\Proponente;
use App\AreaModalidade;
use App\Area;
use App\Revisor;
......@@ -71,6 +73,8 @@ class TrabalhoController extends Controller
$mytime = Carbon::now('America/Recife');
$mytime = $mytime->toDateString();
$evento = Evento::find($request->editalId);
$coordenador = CoordenadorComissao::find($evento->coordenadorId);
//dd($coordenador->id);
if($evento->inicioSubmissao > $mytime){
if($mytime >= $evento->fimSubmissao){
......@@ -83,19 +87,18 @@ class TrabalhoController extends Controller
$validatedData = $request->validate([
'editalId' => ['required', 'integer'],
'nomeProjeto' => ['required', 'string',],
'nomeProjeto' => ['required', 'string'],
'grandeAreaId' => ['required', 'integer'],
'areaId' => ['required', 'integer'],
'subAreaId' => ['required', 'integer'],
'pontuacaoPlanilha' => ['required', 'integer'],
'linkGrupo' => ['required', 'string'],
'linkLattesEstudante' => ['required', 'string'],
'nomeCoordenador' => ['required', 'string'],
'nomeParticipante.*' => ['required', 'string'],
'emailParticipante.*' => ['string'],
'nomePlanoTrabalho.*' => ['string'],
'anexoProjeto' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
//'anexoCONSU' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoLatterCoordenador' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanilha' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
'anexoPlanoTrabalho.*' => ['required', 'file', 'mimes:pdf', 'max:2000000'],
......@@ -103,10 +106,10 @@ class TrabalhoController extends Controller
$trabalho = Trabalho::create([
'titulo' => $request->nomeProjeto,
'coordenador_id' => $coordenador->id,
'grande_area_id' => $request->grandeAreaId,
'area_id' => $request->areaId,
'sub_area_id' => $request->subAreaId,
'coordenador' => $request->nomeCoordenador,
'sub_area_id' => $request->subAreaId,
'pontuacaoPlanilha' => $request->pontuacaoPlanilha,
'linkGrupoPesquisa' => $request->linkGrupo,
'linkLattesEstudante' => $request->linkLattesEstudante,
......@@ -120,6 +123,7 @@ class TrabalhoController extends Controller
'anexoLattesCoordenador' => $request->anexoLatterCoordenador,
'anexoPlanilhaPontuacao' => $request->anexoPlanilha,
]);
//dd($request->all());
}else{
//Caso em que o anexo da Decisão do CONSU não necessário
$validatedData = $request->validate([
......@@ -143,6 +147,7 @@ class TrabalhoController extends Controller
$trabalho = Trabalho::create([
'titulo' => $request->nomeProjeto,
'coordenador_id' => $coordenador->id,
'grande_area_id' => $request->grandeAreaId,
'area_id' => $request->areaId,
'sub_area_id' => $request->subAreaId,
......@@ -163,7 +168,8 @@ class TrabalhoController extends Controller
}
//Relaciona o projeto criado com o proponente que criou o projeto
$trabalho->proponente()->save(Auth()->user());
$proponente = Proponente::where('user_id', Auth::user()->id)->first();
$trabalho->proponentes()->save($proponente);
//Envia email com senha temp para cada participante do projeto
if($request->emailParticipante != null){
......
......@@ -31,6 +31,7 @@ class Trabalho extends Model
'sub_area_id',
'evento_id',
'proponente_id',
'coordenador_id',
];
public function recurso(){
......@@ -77,4 +78,7 @@ class Trabalho extends Model
public function proponentes(){
return $this->belongsToMany('App\Proponente', 'trabalho_proponente');
}
public function coordenador(){
return $this->belongsTo('App\CoordenadorComissao');
}
}
......@@ -22,7 +22,8 @@ class CreateUsersTable extends Migration
$table->string('celular')->nullable();
$table->string('cpf')->nullable();
$table->string('tipo')->nullable();
$table->boolean('usuarioTemp')->nullable();
$table->boolean('usuarioTemp')->nullable();
$table->rememberToken();
$table->timestamps();
$table->timestamp('email_verified_at')->nullable();
......
......@@ -32,7 +32,7 @@ class CreateTrabalhosTable extends Migration
$table->unsignedBigInteger('area_id');
$table->unsignedBigInteger('sub_area_id');
$table->unsignedBigInteger('evento_id');
$table->unsignedBigInteger('proponente_id');
$table->unsignedBigInteger('coordenador_id');
$table->timestamps();
});
......
......@@ -17,6 +17,7 @@ class CreateAreasTable extends Migration
$table->bigIncrements('id');
$table->string('nome');
$table->unsignedBigInteger('grande_area_id');
$table->timestamps();
// $table->integer('modalidadeId')->nullable();
// $table->integer('eventoId');
......
......@@ -14,9 +14,13 @@ class CreateAdministradorsTable extends Migration
public function up()
{
Schema::create('administradors', function (Blueprint $table) {
$table->bigIncrements('id');/*Igor pediu que as PK das tabelas fossem o id */
$table->bigIncrements('id');
$table->string('matricula')->unique();
$table->timestamps();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUsersToAdministradorsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('administradors', function (Blueprint $table) {
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('administradors', function (Blueprint $table) {
//
$table->dropForeign('administradors_user_id_foreign');
$table->dropColumn('user_id');
});
}
}
......@@ -29,6 +29,10 @@ class CreateProponentesTable extends Migration
$table->string('nivel');
$table->string('linkLattes');
$table->timestamps();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUsersToProponentesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('proponentes', function (Blueprint $table) {
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('proponentes', function (Blueprint $table) {
$table->dropForeign('proponentes_user_id_foreign');
$table->dropColumn('user_id');
});
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTrabalhosToProponentesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('proponentes', function (Blueprint $table) {
$table->unsignedBigInteger('trabalho_id')->nullable();
$table->foreign('trabalho_id')->references('id')->on('trabalhos');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('proponentes', function (Blueprint $table) {
$table->dropForeign('proponentes_trabalho_id_foreign');
$table->dropColumn('trabalho_id');
});
}
}
......@@ -18,6 +18,9 @@ class CreatePlanoTrabalhosTable extends Migration
$table->string('titulo');
$table->string('anexoPlanoTrabalho');
$table->timestamps();
$table->unsignedBigInteger('trabalho_id');
$table->foreign('trabalho_id')->references('id')->on('trabalhos');
});
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTrabalhosToPlanoTrabalhosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('plano_trabalhos', function (Blueprint $table) {
$table->unsignedBigInteger('trabalho_id');
$table->foreign('trabalho_id')->references('id')->on('trabalhos');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('plano_trabalhos', function (Blueprint $table) {
$table->dropForeign('plano_trabalhos_trabalho_id_foreign');
$table->dropColumn('trabalho_id');
});
}
}
......@@ -16,6 +16,9 @@ class CreateAdministradorResponsavelsTable extends Migration
Schema::create('administrador_responsavels', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUsersToAdministradorResponsavelsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('administrador_responsavels', function (Blueprint $table) {
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('administrador_responsavels', function (Blueprint $table) {
$table->dropForeign('administrador_responsavels_user_id_foreign');
$table->dropColumn('user_id');
});
}
}
......@@ -16,7 +16,7 @@ class CreateGrandeAreasTable extends Migration
Schema::create('grande_areas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('nome');
$table->timestamps();
$table->timestamps();
});
}
......
......@@ -17,6 +17,10 @@ class CreateSubAreasTable extends Migration
$table->bigIncrements('id');
$table->string("nome");
$table->timestamps();
$table->unsignedBigInteger('area_id');
$table->foreign('area_id')->references('id')->on('areas');
});
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAreasToSubAreasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('sub_areas', function (Blueprint $table) {
$table->unsignedBigInteger('area_id');
$table->foreign('area_id')->references('id')->on('areas');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('sub_areas', function (Blueprint $table) {
$table->dropForeign('sub_areas_area_id_foreign');
$table->dropColumn('area_id');
});
}
}
......@@ -17,6 +17,8 @@ class CreateFuncaoParticipantesTable extends Migration
$table->bigIncrements('id');
$table->string('nome');
$table->timestamps();
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment