Bet.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Models;
  3. class Bet extends BaseModel
  4. {
  5. protected $table = 'bets';
  6. protected $fillable = ['issue_no', 'keywords', 'amount', 'odds', 'status', 'profit', 'issue_id', 'member_id', 'user_id'];
  7. protected $hidden = [];
  8. const STATUS_STAY = 1;
  9. const STATUS_SETTLED = 2;
  10. const STATUS_CANCEL = 3;
  11. function issue()
  12. {
  13. return $this->issue_no;
  14. // return $this->belongsTo(Issue::class, 'issue_no', 'issue_no');
  15. }
  16. public function user()
  17. {
  18. return $this->belongsTo(User::class, 'member_id', 'member_id')
  19. ->select(['id', 'member_id', 'username', 'first_name']);
  20. }
  21. public static $STATUS = [
  22. 1 => '待结算',
  23. 2 => '已结算',
  24. 3 => '取消',
  25. ];
  26. public static function getStatus($val = -1)
  27. {
  28. $array = self::$STATUS;
  29. if ($val < 0) {
  30. $arr = [];
  31. foreach ($array as $k => $v) {
  32. $item = [];
  33. $item['id'] = $k;
  34. $item['title'] = $v;
  35. $arr[] = $item;
  36. }
  37. return $arr;
  38. } else {
  39. return $array[$val];
  40. }
  41. }
  42. }