Recharge.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Models;
  3. use App\Constants\Util;
  4. class Recharge extends BaseModel
  5. {
  6. protected $table = 'recharges';
  7. // protected $fillable = ['member_id', 'confirmations', 'coin', 'txid','block_time','block_height' ,'net' ,'coin' ,'amount' ,'to_address' ,'from_address' ,'status'];
  8. protected $hidden = [];
  9. const STATUS_STAY = 0;
  10. const STATUS_SUCCESS = 1;
  11. const STATUS_FAIL = 2;
  12. const STATUS_IGNORE = 3;
  13. public static $STATUS = [
  14. 0 => '待确认',
  15. 1 => '已确认',
  16. 2 => '失败',
  17. 3 => '已忽略',
  18. ];
  19. const TYPE_AUTO = 1; // 自动
  20. const TYPE_HAND = 2; // 手动
  21. public function member()
  22. {
  23. return $this->belongsTo(User::class, 'member_id', 'member_id')
  24. ->select(['id', 'member_id', 'username', 'first_name', 'status']);
  25. }
  26. protected function getAmountAttribute($value)
  27. {
  28. return floatval($value);
  29. }
  30. protected function getImageAttribute($value)
  31. {
  32. return Util::ensureUrl($value);
  33. }
  34. }