📜  laravel 视图不是使用外键创建的 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:23.280000             🧑  作者: Mango

代码示例1
Schema::create('larachat_chat_rooms', function (Blueprint $table) {
        $table->increments('id');
          //Foreign key must be unsignedBigInteger
        $table->unsignedBigInteger('creator_id');  
        $table->softDeletes();
        $table->timestamps();

        //Define foreign key id here
        $table->foreign('creator_id')->references('id')->on('users')->onDelete('cascade');
    });