Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Classe Pessoa
- class Create_Pessoas {
- public function up(){
- Schema::create('pessoa', function($table){
- $table->increments("ID");
- $table->string('nome', 128);
- $table->timestamps();
- });
- DB::table('pessoa')->insert(array(
- 'nome' => 'Job Control Administrador',
- 'created_at' => Date('H-m-d H:i:s'),
- 'updated_at' => Date('H-m-d H:i:s'),
- ));
- }
- public function down(){
- Schema::drop('pessoa');
- }
- }
- // Especialização da classe para Usuario
- class Create_Usuarios {
- public function up(){
- Schema::create('usuario', function($table){
- $table->integer("pessoa_ID")->unsigned();
- $table->string('login', 20);
- $table->string('senha', 64);
- });
- Schema::table('usuario', function($table){
- $table->foreign('pessoa_ID')->references('ID')->on('pessoa')->on_delete('cascade');
- });
- DB::table('usuario')->insert(array(
- 'login' => 'admin',
- 'senha' => Hash::make('senha'),
- 'pessoa_ID' => 1, // Primeira pessoa adicionada, logicamente com o ID nº 1
- ));
- }
- public function down(){
- Schema::drop('usuario');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment