Files
chatroom/app/Models/BankLog.php

47 lines
818 B
PHP

<?php
/**
* 文件功能:银行流水记录模型
*
* 对应 bank_logs 表,记录每次存款/取款操作及操作后余额。
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class BankLog extends Model
{
/**
* 允许批量赋值的字段
*
* @var list<string>
*/
protected $fillable = [
'user_id',
'type',
'amount',
'balance_after',
];
/**
* 字段类型转换
*/
protected function casts(): array
{
return [
'amount' => 'integer',
'balance_after' => 'integer',
];
}
/**
* 所属用户
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}