Commit acb4245a authored by Guilherme Silva's avatar Guilherme Silva
Browse files

Criação de area tematica

parent 6ebd30af
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AreaTematica extends Model
{
protected $fillable = [
'nome',
];
public function trabalho(){
return $this->hasMany('App\Trabalho', 'area_tematica_id');
}
}
...@@ -38,6 +38,7 @@ class Trabalho extends Model ...@@ -38,6 +38,7 @@ class Trabalho extends Model
'coordenador_id', 'coordenador_id',
'proponente_id', 'proponente_id',
'pivot', 'pivot',
'area_tematica_id',
]; ];
...@@ -64,6 +65,10 @@ class Trabalho extends Model ...@@ -64,6 +65,10 @@ class Trabalho extends Model
return $this->belongsTo('App\SubArea'); return $this->belongsTo('App\SubArea');
} }
public function areaTematica(){
return $this->belongsTo('App\AreaTematica');
}
public function autor(){ public function autor(){
return $this->belongsTo('App\User', 'autorId'); return $this->belongsTo('App\User', 'autorId');
} }
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAreaTematicasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('area_tematicas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('nome');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('area_tematicas');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAreaTematicaToTrabalhosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('trabalhos', function (Blueprint $table) {
$table->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) {
//
});
}
}
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