Commit ee880740 authored by Abraão Barbosa's avatar Abraão Barbosa
Browse files

merge

parent fbaa1a02
...@@ -6,6 +6,32 @@ use Illuminate\Database\Eloquent\Model; ...@@ -6,6 +6,32 @@ use Illuminate\Database\Eloquent\Model;
class Unidade extends Model class Unidade extends Model
{ {
/**
* References table unidade
*
* @var string
*/
protected $table = "unidade";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
/**
* @return string
*/
public function __toString()
{
return $this->name;
}
const ARCOVERDE = 1; const ARCOVERDE = 1;
const CARUARU = 2; const CARUARU = 2;
const GARANHUNS = 3; const GARANHUNS = 3;
...@@ -33,9 +59,9 @@ class Unidade extends Model ...@@ -33,9 +59,9 @@ class Unidade extends Model
self::RECIFE => 'Recife', self::RECIFE => 'Recife',
self::REGIAO_METROPOLITANA => 'Região Metropolitana', self::REGIAO_METROPOLITANA => 'Região Metropolitana',
self::SALGUEIRO => 'Salgueiro', self::SALGUEIRO => 'Salgueiro',
self::SERRA_TALHADA => 'Serra Talhada', self::SERRA_TALHADA => 'Serra Talhada',
]; ];
return $value != null? $values[$value] : $values; return $value != null ? $values[$value] : $values;
} }
} }
...@@ -22,7 +22,8 @@ class CreateUsersTable extends Migration ...@@ -22,7 +22,8 @@ class CreateUsersTable extends Migration
$table->string('password'); $table->string('password');
$table->string('document'); $table->string('document');
$table->tinyInteger('status'); $table->tinyInteger('status');
$table->tinyInteger('unidade'); $table->foreignId('curso_id')->nullable();
$table->foreignId('unidade_id')->nullable();
$table->rememberToken(); $table->rememberToken();
$table->timestamps(); $table->timestamps();
}); });
......
...@@ -16,7 +16,7 @@ class CreateCampusTable extends Migration ...@@ -16,7 +16,7 @@ class CreateCampusTable extends Migration
Schema::create('campus', function (Blueprint $table) { Schema::create('campus', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->tinyInteger('unidade'); $table->foreignId('unidade_id');
$table->timestamps(); $table->timestamps();
}); });
} }
......
...@@ -13,9 +13,9 @@ class CreateCursoInUsersTable extends Migration ...@@ -13,9 +13,9 @@ class CreateCursoInUsersTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::table('users', function (Blueprint $table) { // Schema::table('users', function (Blueprint $table) {
$table->foreignId('curso_id'); // $table->foreignId('curso_id')->nullable();
}); // });
} }
/** /**
...@@ -25,8 +25,8 @@ class CreateCursoInUsersTable extends Migration ...@@ -25,8 +25,8 @@ class CreateCursoInUsersTable extends Migration
*/ */
public function down() public function down()
{ {
if(Schema::hasColumn('users', 'curso_id')) { // if(Schema::hasColumn('users', 'curso_id')) {
Schema::dropColumns('users', ['curso_id']); // Schema::dropColumns('users', ['curso_id']);
} // }
} }
} }
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUnidadeTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('unidade', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('unidade');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUnidadeInUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Schema::create('users', function (Blueprint $table) {
// $table->foreignId('unidade_id')->nullable();
// });
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// if(Schema::hasColumn('users', 'unidade_id')) {
// Schema::dropColumns('users', ['unidade_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