CustomMsgSwitchs.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Modules\OfficialAccount\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class CustomMsgSwitchs extends Model
  5. {
  6. protected $tables = 'custom_msg_switchs';
  7. protected $fillable = ['title','custom_category','status','is_self_content','desc_content','img_url'];
  8. static function customMsgSwitchsBySwitchId($custom_category)
  9. {
  10. return self::where('custom_category',$custom_category)->first();
  11. }
  12. /**
  13. * 获取所有客服消息开关
  14. */
  15. static function getCustomMsgSwitchs()
  16. {
  17. return self::where(['status'=>1])->select('custom_category','id','title')->orderBy('id','asc')->get();
  18. }
  19. /**
  20. * 获取所有客服消息开关
  21. */
  22. static function customMsgSwitchs()
  23. {
  24. return self::select()->get();
  25. }
  26. /**
  27. * 获取类型为键名的所有客服消息开关
  28. */
  29. static function getCustomMsgSwitchByCategorys()
  30. {
  31. $result = array();
  32. $custom_msg_switchs = self::select()->get()->toArray();
  33. foreach($custom_msg_switchs as $key=> $custom_msg_switch){
  34. $result[$custom_msg_switch['custom_category']] = $custom_msg_switch;
  35. }
  36. return $result;
  37. }
  38. }