wp车辆信息

This commit is contained in:
2026-03-09 17:46:17 +08:00
parent 9a0fec3410
commit 25795a4f66
13 changed files with 1277 additions and 268 deletions
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace app\common\model;
use support\Model;
class UsedCarDetail extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'used_car_detail';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'code', 'user_id', 'role_wp', 'product_name', 'vin', 'price', 'source_place', 'plate_place', 'plate_time', 'displacement', 'mileage', 'power', 'body_color', 'images', 'condition_desc', 'attachment', 'pdf_src', 'source_url', 'crawl_title', 'crawl_brand', 'crawl_brand_id', 'crawl_series', 'crawl_series_id', 'crawl_year', 'crawl_msrp', 'crawl_car_id', 'status', 'sort', 'simple_desc', 'intro_images', 'intro_text', 'intro_video', 'official_guide_price', 'manufacturer', 'level', 'energy_type', 'listing_time', 'engine', 'electric_motor', 'nedc_range', 'cltc_range', 'fast_charge_platform', 'charging_time', 'fast_charge_percent', 'max_power_kw', 'max_torque_nm', 'transmission', 'dimensions', 'body_structure', 'max_speed', 'acceleration_100', 'nedc_fuel_consumption', 'power_consumption_100', 'equivalent_fuel_consumption', 'maintenance_cost_60k', 'body_length', 'body_width', 'body_height', 'wheelbase', 'door_count', 'door_open_type', 'seat_count', 'transmission_desc', 'gear_count', 'transmission_type', 'drive_mode', 'front_suspension', 'rear_suspension', 'steering_type', 'has_abs', 'has_ebd', 'has_bra', 'has_tcs', 'has_esp', 'has_active_brake', 'has_lane_assist', 'has_lka', 'has_lane_centering', 'has_fatigue_remind', 'front_brake_type', 'rear_brake_type', 'parking_brake_type', 'front_tire_spec', 'rear_tire_spec', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* JSON 类型字段自动转换
*/
protected $casts = [
'images' => 'array',
'attachment' => 'array',
'intro_images' => 'array',
];
/**
* 关联 FAQ
*/
public function faqs()
{
return $this->hasMany(UsedCarFaq::class, 'car_id', 'id');
}
/**
* 关联用户
*/
public function user()
{
return $this->belongsTo(\app\common\model\User::class, 'user_id', 'id');
}
/**
* 关联审核记录
*/
public function auditRecords()
{
return $this->hasMany(UsedCarDetailAudit::class, 'car_id', 'id')->orderBy('created_at', 'desc');
}
/**
* 最新审核记录
*/
public function latestAudit()
{
return $this->hasOne(UsedCarDetailAudit::class, 'car_id', 'id')->orderBy('created_at', 'desc');
}
/**
* 审核状态文本
*/
public static $auditStatusText = [
0 => '待审核',
1 => '审核通过',
2 => '审核拒绝',
];
/**
* 作用域:待审核
*/
public function scopePending($query)
{
return $query->where('status', 0);
}
/**
* 作用域:已通过
*/
public function scopeApproved($query)
{
return $query->where('status', 1);
}
/**
* 作用域:已拒绝
*/
public function scopeRejected($query)
{
return $query->where('status', 2);
}
}