From acb4245a7268d916a148e177041ac6aacf79b9d8 Mon Sep 17 00:00:00 2001 From: Guilherme Silva Date: Thu, 19 May 2022 14:36:33 -0300 Subject: [PATCH] =?UTF-8?q?Cria=C3=A7=C3=A3o=20de=20area=20tematica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AreaTematica.php | 17 ++++++++++ app/Trabalho.php | 5 +++ ..._18_055323_create_area_tematicas_table.php | 33 +++++++++++++++++++ ...2_add_area_tematica_to_trabalhos_table.php | 33 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 app/AreaTematica.php create mode 100644 database/migrations/2022_05_18_055323_create_area_tematicas_table.php create mode 100644 database/migrations/2022_05_18_055612_add_area_tematica_to_trabalhos_table.php diff --git a/app/AreaTematica.php b/app/AreaTematica.php new file mode 100644 index 0000000..21d71b4 --- /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 15092d6..4cf04c3 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 0000000..2610eaf --- /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 0000000..7d70abc --- /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) { + // + }); + } +} -- GitLab