Files
chatroom/app/Models/BaccaratBet.php

69 lines
1.2 KiB
PHP

<?php
/**
* 文件功能:百家乐下注记录模型
*
* 记录用户在某局中的押注信息和结算状态。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class BaccaratBet extends Model
{
protected $fillable = [
'round_id',
'user_id',
'bet_type',
'amount',
'payout',
'status',
];
/**
* 属性类型转换。
*/
protected function casts(): array
{
return [
'amount' => 'integer',
'payout' => 'integer',
];
}
/**
* 关联局次。
*/
public function round(): BelongsTo
{
return $this->belongsTo(BaccaratRound::class, 'round_id');
}
/**
* 关联用户。
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* 获取押注类型中文名。
*/
public function betTypeLabel(): string
{
return match ($this->bet_type) {
'big' => '大',
'small' => '小',
'triple' => '豹子',
default => '未知',
};
}
}