Payment.php 610 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 支付单
  6. * Class Payment
  7. *
  8. * @package App\Http\Models
  9. */
  10. class Payment extends Model
  11. {
  12. protected $table = 'payment';
  13. public function user()
  14. {
  15. return $this->belongsTo(User::class, 'user_id', 'id');
  16. }
  17. public function order()
  18. {
  19. return $this->belongsTo(Order::class, 'oid', 'oid');
  20. }
  21. function getAmountAttribute($value)
  22. {
  23. return $value / 100;
  24. }
  25. function setAmountAttribute($value)
  26. {
  27. return $this->attributes['amount'] = $value * 100;
  28. }
  29. }