ReferralApply.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Eloquent;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Support\Carbon;
  8. /**
  9. * 返利申请
  10. *
  11. * @property int $id
  12. * @property int $user_id 用户ID
  13. * @property int $before 操作前可提现金额,单位分
  14. * @property int $after 操作后可提现金额,单位分
  15. * @property int $amount 本次提现金额,单位分
  16. * @property string $link_logs 关联返利日志ID,例如:1,3,4
  17. * @property int $status 状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
  18. * @property Carbon|null $created_at 创建时间
  19. * @property Carbon|null $updated_at 最后更新时间
  20. * @property-read User|null $User
  21. * @method static Builder|ReferralApply newModelQuery()
  22. * @method static Builder|ReferralApply newQuery()
  23. * @method static Builder|ReferralApply query()
  24. * @method static Builder|ReferralApply uid()
  25. * @method static Builder|ReferralApply whereAfter($value)
  26. * @method static Builder|ReferralApply whereAmount($value)
  27. * @method static Builder|ReferralApply whereBefore($value)
  28. * @method static Builder|ReferralApply whereCreatedAt($value)
  29. * @method static Builder|ReferralApply whereId($value)
  30. * @method static Builder|ReferralApply whereLinkLogs($value)
  31. * @method static Builder|ReferralApply whereStatus($value)
  32. * @method static Builder|ReferralApply whereUpdatedAt($value)
  33. * @method static Builder|ReferralApply whereUserId($value)
  34. * @mixin Eloquent
  35. */
  36. class ReferralApply extends Model {
  37. protected $table = 'referral_apply';
  38. protected $primaryKey = 'id';
  39. function scopeUid($query) {
  40. return $query->whereUserId(Auth::user()->id);
  41. }
  42. function User() {
  43. return $this->hasOne(User::class, 'id', 'user_id');
  44. }
  45. function getBeforeAttribute($value) {
  46. return $value / 100;
  47. }
  48. function setBeforeAttribute($value) {
  49. $this->attributes['before'] = $value * 100;
  50. }
  51. function getAfterAttribute($value) {
  52. return $value / 100;
  53. }
  54. function setAfterAttribute($value) {
  55. $this->attributes['after'] = $value * 100;
  56. }
  57. function getAmountAttribute($value) {
  58. return $value / 100;
  59. }
  60. function setAmountAttribute($value) {
  61. $this->attributes['amount'] = $value * 100;
  62. }
  63. }