DistributionSelfDefineConfig.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Modules\OfficialAccount\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class DistributionSelfDefineConfig extends Model
  5. {
  6. protected $connection = 'api_mysql';
  7. protected $tables = 'distribution_self_define_configs';
  8. protected $fillable = ['distribution_channel_id','company_id','account','content','desc','status','type','created_at','updated_at'];
  9. static function getDistributionSelfDefineConfig($distribution_channel_id,$type)
  10. {
  11. return self::where(['distribution_channel_id'=>$distribution_channel_id,'type'=>$type,'status'=>1])->first();
  12. }
  13. static function getDistributionChannelSwitchByCategoryAndCompany($company_id,$type)
  14. {
  15. return self::where(['company_id'=>$company_id,'type'=>$type,'status'=>1])->first();
  16. }
  17. static function getDistributionChannelSwitchByCategoryAndAccount($account,$type){
  18. return self::where(['account'=>$account,'type'=>$type,'status'=>1])->first();
  19. }
  20. static function getDistributionsByType($type)
  21. {
  22. return self::where(['type'=>$type,'status'=>1])->get();
  23. }
  24. static function getDistributionIdsByType($type):array{
  25. return self::where(['type'=>$type,'status'=>1])->get()->pluck('distribution_channel_id')->all();
  26. }
  27. }