59 lines
1.0 KiB
PHP
59 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\Model;
|
||
|
|
|
||
|
|
use support\Model;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 二手车PDF生成日志模型
|
||
|
|
*/
|
||
|
|
class UsedCarPdfLog extends Model
|
||
|
|
{
|
||
|
|
protected $table = 'used_car_pdf_log';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'user_id',
|
||
|
|
'used_car_id',
|
||
|
|
'price_snapshot',
|
||
|
|
'pdf_path',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'price_snapshot' => 'integer',
|
||
|
|
'created_at' => 'datetime',
|
||
|
|
'updated_at' => 'datetime',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 关联用户
|
||
|
|
*/
|
||
|
|
public function user()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'user_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 关联二手车
|
||
|
|
*/
|
||
|
|
public function usedCar()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(UsedCar::class, 'used_car_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 作用域:按二手车筛选
|
||
|
|
*/
|
||
|
|
public function scopeByUsedCar($query, int $usedCarId)
|
||
|
|
{
|
||
|
|
return $query->where('used_car_id', $usedCarId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 作用域:按用户筛选
|
||
|
|
*/
|
||
|
|
public function scopeByUser($query, int $userId)
|
||
|
|
{
|
||
|
|
return $query->where('user_id', $userId);
|
||
|
|
}
|
||
|
|
}
|