Skip to content
Snippets Groups Projects
Commit a1b0bef0 authored by Kurniandha Sukma Yunastrian's avatar Kurniandha Sukma Yunastrian
Browse files

add migration

parent c73d1da4
Branches
2 merge requests!8Finalize,!1add migration
Pipeline #22786 failed with stages
......@@ -68,6 +68,7 @@ class RegisterController extends Controller
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'role' => 'member',
]);
}
}
......@@ -16,7 +16,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'name', 'email', 'password', 'role',
];
/**
......
......@@ -23,6 +23,7 @@ $factory->define(User::class, function (Faker $faker) {
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'role' => 'member',
'remember_token' => Str::random(10),
];
});
......@@ -19,6 +19,7 @@ class CreateUsersTable extends Migration
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('role');
$table->rememberToken();
$table->timestamps();
});
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCoursesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('courses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('description');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('courses');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTopicsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('topics', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('id_course')->unsigned();
$table->string('name');
$table->string('content');
$table->foreign('id_course')->references('id')->on('courses');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('topics');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSpreadsheetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('spreadsheets', function (Blueprint $table) {
$table->bigInteger('id_topic')->unsigned();
$table->string('cell');
$table->string('value');
$table->string('type');
$table->primary(['id_topic', 'cell']);
$table->foreign('id_topic')->references('id')->on('topics');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('spreadsheets');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGradesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('grades', function (Blueprint $table) {
$table->bigInteger('id_course')->unsigned();
$table->bigInteger('id_user')->unsigned();
$table->bigInteger('id_topic')->unsigned();
$table->integer('grade');
$table->primary(['id_course', 'id_user', 'id_topic']);
$table->foreign('id_course')->references('id')->on('courses');
$table->foreign('id_user')->references('id')->on('users');
$table->foreign('id_topic')->references('id')->on('topics');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('grades');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUserCourseTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_course', function (Blueprint $table) {
$table->bigInteger('id_user')->unsigned();
$table->bigInteger('id_course')->unsigned();
$table->string('role');
$table->primary(['id_user', 'id_course']);
$table->foreign('id_user')->references('id')->on('users');
$table->foreign('id_course')->references('id')->on('courses');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_course');
}
}
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