laravel查出软删除 deleted_at is not null 的内容, laravel database migration

\Illuminate\Database\Eloquent\SoftDeletingScope;

$query->withoutGlobalScope(SoftDeletingScope::class)
    ->where($article->getDeletedAtColumn(), "<>", null);
withoutGlobalScope(SoftDeletingScope::class)
            ->where($article->getDeletedAtColumn(), "<>", null);
        return $query;
    }
}

laravel database migration

php artisan make:migration create_article_read_table

先生成迁移文件./database/migrations/2021_06_17_093830_create_article_read_table.php

补充up方法

        Schema::create('life_cms_article_read', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('content_id')->comment('文章id');
            $table->integer('user_id')->comment('用户id');
            $table->tinyInteger('type')->comment('1.会员用户 2商户用户');
            $table->tinyInteger('read_status')->default(0)->comment('状态 1 已读 0 未读 -1 删除');
            $table->timestamps();
        });

生成表: 

php artisan migrate --path=./database/migrations/2021_06_17_093830_create_article_read_table.php

修改字段后更新表结构

php artisan migrate --path=./database/migrations/2021_08_17_095756_xx_log.php

回滚

php artisan migrate:rollback --step=1

你可能感兴趣的:(php,laravel)