Fakultas Ilmu Komputer UI

Commit 5a37c9cf authored by aabccd021's avatar aabccd021
Browse files

created mahasiswa model and migrations

parent 66595810
......@@ -16,6 +16,6 @@ class AdminerDatabase extends Model
];
public function user() {
return $this->belongsTo('App\Models\User');
return $this->belongsTo('App\Models\Mahasiswa');
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Mahasiswa extends Model
{
use HasFactory, SoftDeletes;
protected $fillabel = [
'user_id',
'password'
]
}
\ No newline at end of file
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMahasiswaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('mahasiswa', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('user_id')->unique();
$table->string('password');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('mahasiswa');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserIdFkToAdminerDatabaseTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('adminer_databases', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('mahasiswa');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('adminer_databases', function (Blueprint $table) {
$table->dropForeign(['user_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