php Laravel 5.8级联删除

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Laravel 5.8级联删除相关的知识,希望对你有一定的参考价值。


<?php
/*
add InnoDB line to both, the current migration table and the target migration table
*/
public function up()
{
    Schema::create('registrations', function (Blueprint $table) {
        $table->engine = "InnoDB"; // engine handles foreign key constraints
        // $table->BigIncrements('id'); // shit breaks cascade down function, what a headache, needs to be "increments"
        $table->increments('id');
        $table->integer('user_id')->unsigned()->nullable() ;
       // $table->string('key_num'); // migrated to users table
        $table->dateTime('event_date') ;
        $table->timestamps();
    });

    // ON DELETE USER, DELETE ALL REGISTRATIONS THAT BELONG TO THIS USER
    Schema::table('registrations', function (Blueprint $table) {
        $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade');
    });

}





以上是关于php Laravel 5.8级联删除的主要内容,如果未能解决你的问题,请参考以下文章

未找到 Laravel 5.8 自定义命令

将 PHP 数组传递给 JS - PHP Laravel 5.8 [重复]

Laravel Eloquent 级联删除

Laravel 4 级联软删除

在Laravel 5.8中覆盖默认的Auth路由

PHP 致命错误:未捕获的错误:使用 Laravel 5.8 和 PHP 7.4 调用未定义函数 Whoops\Exception\xdebug_is_enabled()