zoukankan      html  css  js  c++  java
  • laravel为模型中所有查询统一添加WHERE条件

    第一种方法

    <?php
    namespace Table;
    use IlluminateDatabaseEloquentBuilder;
    /**
    *
    *
    */
    class TSingleService extends Table{
         
        protected $table = 'single_service_list';
        public $timestamps = false;
    
        /**
         * 设置单项服务全局查询条件
        */
        protected static function boot()
         {
             parent::boot(); // TODO: Change the autogenerated stub
             static::addGlobalScope('avaiable',function (Builder $builder){
                 $builder->where('deleted_at','=',NULL);
             });
         }
    }

      

    第二种方法

    <?php
    namespace Table;
    
    use IlluminateDatabaseEloquentSoftDeletes;
    /**
    *
    *
    */
    class TSingleService extends Table{
        use SoftDeletes;
        protected $table = 'single_service_list';
        protected $dates = ['deleted_at'];
        public $timestamps = false;
    
    }
    

      

  • 相关阅读:
    抓取国家地区基础数据
    h264
    h.264
    vlc 推送rtsp视频流不能播放
    花生壳tcp内网端口映射
    make 安装时指定目录
    ubuntu安装vsftpd
    vsftpd命令
    vim删除某一列
    linux打开防火墙
  • 原文地址:https://www.cnblogs.com/guduershi/p/13396798.html
Copyright © 2011-2022 走看看