RoomUser.php 899 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Models;
  3. use App\Constants\Util;
  4. class RoomUser extends BaseModel
  5. {
  6. protected $table = 'room_users';
  7. protected $fillable = ['room_id', 'member_id', 'game_id', 'status', 'score', 'screenshot', 'game_id', 'first_name'];
  8. public function room()
  9. {
  10. return $this->belongsTo(Room::class, 'room_id', 'room_id');
  11. }
  12. protected function getBrokerageAttribute($value)
  13. {
  14. return floatval($value);
  15. }
  16. protected function getScoreAttribute($value)
  17. {
  18. return floatval($value);
  19. }
  20. protected function getRealScoreAttribute($value)
  21. {
  22. return floatval($value);
  23. }
  24. protected function getScreenshotAttribute($value)
  25. {
  26. return Util::ensureUrl($value);
  27. }
  28. protected function setScreenshotAttribute($value)
  29. {
  30. $this->attributes['screenshot'] = Util::replacePartInUrl($value);
  31. }
  32. }