QappPushTask.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Modules\Push\Models;
  3. use App\Consts\PushConst;
  4. use Illuminate\Database\Eloquent\Model;
  5. class QappPushTask extends Model
  6. {
  7. protected $table = 'qapp_push_task';
  8. protected $fillable = ['uid', 'package_id', 'type', 'title', 'content', 'url', 'num',
  9. 'status', 'providers', 'push_time', 'push_filter', 'push_result', 'select_user_status'];
  10. /**
  11. * @param $id
  12. * @return array
  13. */
  14. public static function getPushTaskById($id)
  15. {
  16. if (empty($id)) {
  17. return [];
  18. }
  19. return self::where('id', $id)->first();
  20. }
  21. /**
  22. * @param $id
  23. * @param $data
  24. * @return bool
  25. */
  26. public static function updatePushTask($id, $data): bool
  27. {
  28. if (empty($id) || empty($data)) {
  29. return false;
  30. }
  31. return self::where('id', $id)->update($data);
  32. }
  33. /**
  34. * @return mixed
  35. */
  36. public static function getValidTask()
  37. {
  38. return self::where('status', PushConst::PUSH_STATUS_TODO)
  39. ->where('select_user_status', PushConst::SELECT_USER_OK)
  40. ->orderBy('push_time', 'ASC')
  41. ->first();
  42. }
  43. }