QappPushApp.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Modules\Push\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class QappPushApp extends Model
  5. {
  6. protected $table = 'qapp_push_app';
  7. protected $fillable = ['uid', 'package_id', 'package', 'app_id', 'app_secret', 'app_key', 'master_key',
  8. 'name', 'config_json', 'provider', 'status'];
  9. public static function getPushAppByAppId($appId)
  10. {
  11. if (empty($appId)) {
  12. return [];
  13. }
  14. return self::where('app_id', $appId)->where('status', 1)->first();
  15. }
  16. /**
  17. * @param $package
  18. * @param $provider
  19. * @return array
  20. */
  21. public static function getPushAppByPackageAndProvider($package, $provider)
  22. {
  23. if (empty($package) || empty($provider)) {
  24. return [];
  25. }
  26. return self::where('package', $package)->where('provider', strtolower($provider))->where('status', 1)->first();
  27. }
  28. /**
  29. * @param $packageId
  30. * @param $provider
  31. * @return array
  32. */
  33. public static function getPushAppByPackageIdAndProvider($packageId, $provider)
  34. {
  35. if (empty($packageId) || empty($provider)) {
  36. return [];
  37. }
  38. return self::where('package_id', $packageId)->where('provider', strtolower($provider))->where('status', 1)->first();
  39. }
  40. /**
  41. * @param $packageId
  42. * @return array
  43. */
  44. public static function getPushAppByPackageId($packageId): array
  45. {
  46. if (empty($packageId)) {
  47. return [];
  48. }
  49. $result = self::where('package_id', $packageId)->where('status', 1)->get();
  50. return $result ? $result->toArray() : [];
  51. }
  52. /**
  53. * @param $appIds
  54. * @return array
  55. */
  56. public static function getPushAppByAppIds($appIds): array
  57. {
  58. if (empty($appIds)) {
  59. return [];
  60. }
  61. $result = self::whereIn('app_id', $appIds)->where('status', 1)->get();
  62. return $result ? $result->toArray() : [];
  63. }
  64. }