belongsTo(UsersModel::class, 'user_id', 'id'); } public function brand() { return $this->belongsTo(BrandModel::class, 'brand', 'id'); } public function types() { return $this->belongsTo(TypesModel::class, 'type', 'id'); } public function energy() { return $this->belongsTo(EnergyModel::class, 'energy', 'id'); } public function models() { return $this->belongsTo(ModelModel::class, 'model', 'id'); } public function album() { return $this->hasOne(VehicleAlbumModel::class, 'vehicle_data_id', 'id'); } public function thumb() { return $this->belongsTo(VehicleAlbumModel::class, 'vehicle_id', 'id')->select('front_45_degree'); } public function location() { return $this->belongsTo(LocationModel::class, 'location'); } /** * 单条翻译 */ public function translation() { return $this->hasOne(VehicleDataTranslationModel::class, 'vehicle_id')->where('locale', locale()); } /** * 多条翻译 */ public function translations() { return $this->hasMany(VehicleDataTranslationModel::class, 'vehicle_id'); } const TRANS_FIELDS = [ 'name', 'condition_desc' ]; const STORE_STATUS = [ 1 => '现货', 2 => '在途', 3 => '订购', ]; const STORE_STATUS_VALUE = [ 1 => 'in_stock', 2 => 'in_transit', 3 => 'in_order', ]; }