'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); } }