RoomUser.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. * @mixin Builder
  9. * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
  10. */
  11. class RoomUser extends Authenticatable
  12. {
  13. use HasApiTokens, Notifiable;
  14. protected $table = 'room_users';
  15. protected $hidden = ['created_at', 'updated_at'];
  16. protected $fillable = ['room_id', 'member_id', 'game_id', 'status', 'score', 'screenshot', 'game_id', 'first_name'];
  17. public function room()
  18. {
  19. return $this->belongsTo(Room::class, 'room_id', 'room_id');
  20. }
  21. protected function getBrokerageAttribute($value)
  22. {
  23. return floatval($value);
  24. }
  25. protected function getScoreAttribute($value)
  26. {
  27. return floatval($value);
  28. }
  29. protected function getRealScoreAttribute($value)
  30. {
  31. return floatval($value);
  32. }
  33. protected function getCreatedAtAttribute($value)
  34. {
  35. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  36. }
  37. protected function getUpdatedAtAttribute($value)
  38. {
  39. return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
  40. }
  41. }