当前位置 博文首页 > at is not null 的内容, laravel database migration_fareast_mz

    at is not null 的内容, laravel database migration_fareast_mz

    作者:[db:作者] 时间:2021-08-13 15:54

    $query->withoutGlobalScope(SoftDeletingScope::class)
        ->where($article->getDeletedAtColumn(), "<>", null);
    <?php
    
    namespace CmsV2\Services\Articles;
    
    use CmsV2\Models\Article;
    use Illuminate\Database\Eloquent\SoftDeletingScope;
    use Illuminate\Database\Query\Builder;
    
    class ArticleTrashListService extends ArticlesListService
    {
        /**
         * 添加过滤条件
         * @return \Illuminate\Database\Eloquent\Builder
         * @throws \Exception
         */
        public function query() {
            /** @var $query Builder */
            $query = parent::query();
            $article = new Article();
            $query->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

    cs