diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c6a6de672709676254ebf05f4ddd5597972645cd..f6022acda6bf7e331a4cec1a6d090baa5909fe1b 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -68,6 +68,7 @@ class RegisterController extends Controller 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), + 'role' => 'member', ]); } } diff --git a/app/User.php b/app/User.php index e79dab7fea8f6601eaf07072ee6b12fbe20bdbe1..b5aabd6ede69bab226da638c8629786c18344dfb 100644 --- a/app/User.php +++ b/app/User.php @@ -16,7 +16,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', + 'name', 'email', 'password', 'role', ]; /** diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 741edead6192a670fb2b10e4fbf303ab2ab3be12..3618ad9af9a8f08271e4fc97dab0e047e034e890 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -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), ]; }); diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index a91e1d3c4baed140741e1eb20305b2f13f6ee468..2bcef7d354b5848e50b5556324bdcd9bd298d072 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -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(); }); diff --git a/database/migrations/2020_03_11_190605_create_courses_table.php b/database/migrations/2020_03_11_190605_create_courses_table.php new file mode 100644 index 0000000000000000000000000000000000000000..3b34a1a384200aba13261b1c7e0d11d80a07c169 --- /dev/null +++ b/database/migrations/2020_03_11_190605_create_courses_table.php @@ -0,0 +1,32 @@ +<?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'); + } +} diff --git a/database/migrations/2020_03_11_190629_create_topics_table.php b/database/migrations/2020_03_11_190629_create_topics_table.php new file mode 100644 index 0000000000000000000000000000000000000000..3ac031cfe59f3317ceee682b5d1ac64fd5808094 --- /dev/null +++ b/database/migrations/2020_03_11_190629_create_topics_table.php @@ -0,0 +1,35 @@ +<?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'); + } +} diff --git a/database/migrations/2020_03_11_190641_create_spreadsheets_table.php b/database/migrations/2020_03_11_190641_create_spreadsheets_table.php new file mode 100644 index 0000000000000000000000000000000000000000..0a754dd35dd037dfff1ec2c52275f19b64cec4a3 --- /dev/null +++ b/database/migrations/2020_03_11_190641_create_spreadsheets_table.php @@ -0,0 +1,36 @@ +<?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'); + } +} diff --git a/database/migrations/2020_03_11_190651_create_grades_table.php b/database/migrations/2020_03_11_190651_create_grades_table.php new file mode 100644 index 0000000000000000000000000000000000000000..5fba8613a9a9f3b40c138c1d5ad6676b1d1f88f2 --- /dev/null +++ b/database/migrations/2020_03_11_190651_create_grades_table.php @@ -0,0 +1,39 @@ +<?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'); + } +} diff --git a/database/migrations/2020_03_11_190702_create_user_course_table.php b/database/migrations/2020_03_11_190702_create_user_course_table.php new file mode 100644 index 0000000000000000000000000000000000000000..4d45657958474a85d3dd6baeb6b6c51499a3128f --- /dev/null +++ b/database/migrations/2020_03_11_190702_create_user_course_table.php @@ -0,0 +1,37 @@ +<?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'); + } +}