diff --git a/app/AreaTematica.php b/app/AreaTematica.php new file mode 100644 index 0000000000000000000000000000000000000000..21d71b48569cdf0aaefdb383cdcdeb7024121323 --- /dev/null +++ b/app/AreaTematica.php @@ -0,0 +1,17 @@ +hasMany('App\Trabalho', 'area_tematica_id'); + } + +} diff --git a/app/Trabalho.php b/app/Trabalho.php index 15092d67f88c8db8377296d1420cdd7b720e882b..4cf04c391a08b09853c3a1947837e96029661799 100755 --- a/app/Trabalho.php +++ b/app/Trabalho.php @@ -38,6 +38,7 @@ class Trabalho extends Model 'coordenador_id', 'proponente_id', 'pivot', + 'area_tematica_id', ]; @@ -64,6 +65,10 @@ class Trabalho extends Model return $this->belongsTo('App\SubArea'); } + public function areaTematica(){ + return $this->belongsTo('App\AreaTematica'); + } + public function autor(){ return $this->belongsTo('App\User', 'autorId'); } diff --git a/database/migrations/2022_05_18_055323_create_area_tematicas_table.php b/database/migrations/2022_05_18_055323_create_area_tematicas_table.php new file mode 100644 index 0000000000000000000000000000000000000000..2610eaf20a379a12cc460af394714ffbd3daeb13 --- /dev/null +++ b/database/migrations/2022_05_18_055323_create_area_tematicas_table.php @@ -0,0 +1,33 @@ +bigIncrements('id'); + $table->string('nome'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('area_tematicas'); + } +} diff --git a/database/migrations/2022_05_18_055612_add_area_tematica_to_trabalhos_table.php b/database/migrations/2022_05_18_055612_add_area_tematica_to_trabalhos_table.php new file mode 100644 index 0000000000000000000000000000000000000000..7d70abcceba31e529b486065f1db808a070ec0f5 --- /dev/null +++ b/database/migrations/2022_05_18_055612_add_area_tematica_to_trabalhos_table.php @@ -0,0 +1,33 @@ +integer('area_tematica_id')->nullable(); + $table->foreign('area_tematica_id')->references('id')->on('area_tematicas'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('trabalhos', function (Blueprint $table) { + // + }); + } +}