I am getting these errors while creating a pivot table and migrating it. This is my code for pivot table.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class HotelUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('hotel_user', function (Blueprint $table) {
$table->integer('hotel_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->foreign('hotel_id')->refrences('id')->on('hotels');
$table->foreign('user_id')->refrences('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('hotel_user');
}
}
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 (SQL: alter table
hotel _user
add constrainthotel_user_hotel_id_foreign
foreign key (hotel_id
) referenceshotels
())
In Connection.php line 452:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1