Recharge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Models;
  3. use App\Constants\HttpStatus;
  4. use App\Constants\Util;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. use Laravel\Sanctum\HasApiTokens;
  8. use Illuminate\Database\Eloquent\Builder;
  9. /**
  10. * @mixin Builder
  11. * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
  12. */
  13. class Recharge extends Authenticatable
  14. {
  15. use HasApiTokens, Notifiable;
  16. protected $table = 'recharges';
  17. // protected $hidden = ['created_at', 'updated_at'];
  18. // protected $fillable = ['member_id', 'confirmations', 'coin', 'txid','block_time','block_height' ,'net' ,'coin' ,'amount' ,'to_address' ,'from_address' ,'status'];
  19. const STATUS_STAY = 0;
  20. const STATUS_SUCCESS = 1;
  21. const STATUS_FAIL = 2;
  22. const STATUS_IGNORE = 3;
  23. public static $STATUS = [
  24. 0 => '待确认',
  25. 1 => '已确认',
  26. 2 => '失败',
  27. 3 => '已忽略',
  28. ];
  29. const TYPE_AUTO = 1; // 自动
  30. const TYPE_HAND = 2; // 手动
  31. protected function getAmountAttribute($value)
  32. {
  33. return floatval($value);
  34. }
  35. protected function getImageAttribute($value)
  36. {
  37. return Util::ensureUrl($value);
  38. }
  39. protected function getCreatedAtAttribute($value)
  40. {
  41. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  42. }
  43. protected function getUpdatedAtAttribute($value)
  44. {
  45. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  46. }
  47. }