Bet.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Builder;
  4. use Illuminate\Foundation\Auth\User as Authenticatable;
  5. use Illuminate\Notifications\Notifiable;
  6. use Laravel\Sanctum\HasApiTokens;
  7. /**
  8. * Bet
  9. * @mixin Builder
  10. * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
  11. */
  12. class Bet extends Authenticatable
  13. {
  14. use HasApiTokens, Notifiable;
  15. protected $table = 'bets';
  16. // protected $hidden = ['created_at', 'updated_at'];
  17. protected $fillable = ['issue_no', 'keywords', 'amount' ,'odds' ,'status' ,'profit' ,'issue_id' ,'member_id' ,'user_id'];
  18. const STATUS_STAY = 1;
  19. const STATUS_SETTLED = 2;
  20. const STATUS_CANCEL = 3;
  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. protected function getCreatedAtAttribute($value)
  43. {
  44. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  45. }
  46. protected function getUpdatedAtAttribute($value)
  47. {
  48. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  49. }
  50. // public function children()
  51. // {
  52. // return $this->hasMany(Menu::class, 'parent_id');
  53. // }
  54. // public function parent()
  55. // {
  56. // return $this->belongsTo(Menu::class, 'parent_id');
  57. // }
  58. }