I have a table User, which has an id. In another table (AdminUser), I want to reference it, but with camelCase convention.
However, Laravel doesn’t convert that and/or recognize the user table, so it returns always null when asking for the user from the other table.
I am experimenting with something, so the table layout User and AdminUser might be weird, but that is not the point of the question.
Here is the AdminUser table:
Schema::create('AdminUser', function (Blueprint $table) {
$table->id();
$table->foreign('userId');
$table->integer('pin');
$table->string('passcode');
$table->timestamp('updatedAt');
$table->timestamp('createdAt');
});
Here is the User table:
Schema::create('User', function (Blueprint $table) {
$table->id();
$table->string('username');
$table->string('password');
$table->enum('role', ['ADMIN', 'USER'])->default('USER');
$table->string('loginToken')->nullable();
$table->rememberToken()->nullable();
$table->renameColumn('remember_token', 'rememberToken');
$table->timestamp('createdAt');
$table->timestamp('updatedAt');
});
If I reference it with user_id in the AdminUser table, it is working properly, but I would like to find out how to use camelCase foreign keys.