"resources/views/git@sites.upe.br:walter.felipe/submeta.git" did not exist on "fb053722292189a1cb41493fdc17623e5c37d495"
Commit 7f791e6c authored by alissonalbuquerque's avatar alissonalbuquerque
Browse files

Merge branch 'table-disciplina'

parents 2d69c156 1b3dad4e
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Disciplina extends Model
{
use HasFactory;
/**
* References table disciplinas
*
* @var string
*/
protected $table = 'disciplinas';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'curso_id'];
/**
* Get Curso with curso.id = disciplinas.curso_id
*
* @return Curso
*/
public function curso()
{
return $this->belongsTo(Curso::class);
}
/**
* @return string
*/
public function __toString()
{
return $this->name;
}
}
...@@ -16,7 +16,8 @@ class PlanejamentoQuery extends Query { ...@@ -16,7 +16,8 @@ class PlanejamentoQuery extends Query {
* @return Builder * @return Builder
*/ */
public function whereDimensao(int $dimensao, string $expression = '=') { public function whereDimensao(int $dimensao, string $expression = '=') {
return $this->query->where('dimensao', $expression, $dimensao); $this->query = $this->query->where('dimensao', $expression, $dimensao);
return $this->query;
} }
/** /**
...@@ -25,7 +26,8 @@ class PlanejamentoQuery extends Query { ...@@ -25,7 +26,8 @@ class PlanejamentoQuery extends Query {
* @return Builder * @return Builder
*/ */
public function whereCodDimensao(string $cod_dimensao, string $expression = '=') { public function whereCodDimensao(string $cod_dimensao, string $expression = '=') {
return $this->query->where('cod_dimensao', $expression, $cod_dimensao); $this->query = $this->query->where('cod_dimensao', $expression, $cod_dimensao);
return $this->query;
} }
/** /**
...@@ -34,7 +36,8 @@ class PlanejamentoQuery extends Query { ...@@ -34,7 +36,8 @@ class PlanejamentoQuery extends Query {
* @return Builder * @return Builder
*/ */
public function whereInCodDimensao($codes_dimensao) { public function whereInCodDimensao($codes_dimensao) {
return $this->query->whereIn('cod_dimensao', $codes_dimensao); $this->query = $this->query->whereIn('cod_dimensao', $codes_dimensao);
return $this->query;
} }
} }
\ No newline at end of file
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDisciplinasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('disciplinas', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->foreignId('curso_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('disciplinas');
}
}
...@@ -22,6 +22,7 @@ class DatabaseSeeder extends Seeder ...@@ -22,6 +22,7 @@ class DatabaseSeeder extends Seeder
CursoSeeder::class, CursoSeeder::class,
UserSeeder::class, UserSeeder::class,
PlanejamentoSeeder::class, PlanejamentoSeeder::class,
DisciplinaSeeder::class,
]); ]);
} }
} }
<?php
namespace Database\Seeders;
use App\Models\Curso;
use App\Models\Disciplina;
use Illuminate\Database\Seeder;
class DisciplinaSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$cursos = Curso::all();
$disciplinas = ['Disciplina A', 'Disciplina B', 'Disciplina C', 'Disciplina D', 'Disciplina E'];
foreach($cursos as $curso) {
foreach($disciplinas as $disciplina) {
Disciplina::create([
'name' => $curso->name .' - '. $disciplina,
'curso_id' => $curso->id,
]);
}
}
}
}
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