You change the relationship to a many-to-many instead of a one-to-many, then you can add as many roles as you like to each user.
Feb 13, 2024
5
Level 1
How to create system for 'change role permisson'
so I have 3 roles, namely Admin, Lecturer and Student. I want to use both roles in 1 account for Lecturers and Students. Can I create a role replacement system? How to make this system, give me input and suggestions
users
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id(); // primary key
// main data
$table->bigInteger('nidn');
$table->string('fullname');
$table->string('email')->unique();
$table->string('password');
// detail
$table->enum('faculty', ['FTIK', 'FEIS']);
$table->string('major')->nullable();
$table->string('telp')->unique()->nullable();
$table->date('birthdate')->nullable();
$table->enum('gender', ['F', 'M'])->nullable();
$table->text('address')->nullable();
$table->text('image')->nullable();
// identifier
$table->enum('role', ['Admin', 'Lecturer', 'Student'])->default('Lecturer');
// system
$table->timestamp('email_verified_at')->nullable();
$table->timestamps();
$table->rememberToken();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Please or to participate in this conversation.