CustomMsgSwitchsMsgs.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Modules\OfficialAccount\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class CustomMsgSwitchsMsgs extends Model
  5. {
  6. protected $tables = 'custom_msg_switchs_msgs';
  7. protected $fillable = ['status','distribution_channel_id','custom_category','is_self_content'];
  8. /**
  9. * 获取指定客服消息开关
  10. */
  11. static function customMsgSwitchsByChannelCate($distribution_channel_id,$custom_category)
  12. {
  13. return self::where(['distribution_channel_id'=>$distribution_channel_id,'custom_category'=>$custom_category])->first();
  14. }
  15. /**
  16. * 根据distribution_channel_id获取所有客服消息开关
  17. */
  18. static function customMsgSwitchsMsgsByChannelId($distribution_channel_id)
  19. {
  20. return self::where('distribution_channel_id',$distribution_channel_id)->get();
  21. }
  22. function customMsgSwitchs(){
  23. return $this->hasOne('App\Modules\OfficialAccount\Models\CustomMsgSwitchs','custom_category','custom_category');
  24. }
  25. }