OfficialAccountMsg.php 762 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Modules\OfficialAccount\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class OfficialAccountMsg extends Model
  5. {
  6. protected $connection = 'api_mysql';
  7. protected $table = 'official_account_msgs';
  8. //获取事件回复
  9. static function getEventMsg($params)
  10. {
  11. $appid = $params['appid'];
  12. $apply_event_key = $params['apply_event_key'];
  13. $apply_event = $params['apply_event'];
  14. $search = self::where('appid',$appid)->where('apply_event',$apply_event)->active();
  15. if($apply_event_key) $search->where('apply_event_key',$apply_event_key);
  16. return $search->first();
  17. }
  18. //有效
  19. public function scopeActive($query)
  20. {
  21. return $query->where('status', 1);
  22. }
  23. }