新增银行功能:存取金币、流水记录、PC/手机端双入口;迁移 bank_jjb 字段和 bank_logs 表
This commit is contained in:
46
app/Models/BankLog.php
Normal file
46
app/Models/BankLog.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user