Merge branch 'feature/brand'

This commit is contained in:
2025-06-04 11:04:01 +08:00
116 changed files with 7676 additions and 27 deletions
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandBannerModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_banner';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'pic', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(BrandBannerTranslationModel::class, 'banner_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleDataTranslationModel::class, 'banner_id');
}
const TRANS_FIELDS = [
'alt'
];
}
@@ -0,0 +1,68 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandBannerTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_banner_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'banner_id', 'alt', 'locale', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
public function banner()
{
return $this->belongsTo(BrandBannerModel::class, 'banner_id');
}
}
+10 -1
View File
@@ -47,7 +47,7 @@ class BrandModel extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'status', 'sort', 'created_at', 'updated_at'];
protected $fillable = ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'is_hot', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
@@ -64,4 +64,13 @@ class BrandModel extends Model
{
return $this->hasMany(BrandTranslationModel::class, 'brand_id');
}
public function banner()
{
return $this->hasMany(BrandBannerModel::class, 'brand_id','id');
}
public function trait()
{
return $this->hasMany(BrandTraitModel::class, 'brand_id','id');
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandTraitModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_trait';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(BrandTraitTranslationModel::class, 'trait_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(BrandTraitTranslationModel::class, 'trait_id');
}
const TRANS_FIELDS = [
'title', 'content'
];
}
@@ -0,0 +1,67 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandTraitTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_trait_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'trait_id', 'locale', 'title', 'content', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
public function brandTrait()
{
return $this->belongsTo(BrandTraitModel::class, 'trait_id');
}
}
+15 -1
View File
@@ -47,7 +47,7 @@ class BrandTranslationModel extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'locale', 'name'];
protected $fillable = ['id', 'brand_id', 'locale', 'name', 'desc','toppic_alt','descpic_alt','logo_alt'];
/**
* 不允许自动填充模型字段
@@ -59,4 +59,18 @@ class BrandTranslationModel extends Model
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
// 初始化钩子
public static function boot()
{
parent::boot();
// 保存后触发(包括创建和更新)
static::saved(function ($model) {
// 业务逻辑
if($model->locale == 'en'){
BrandModel::updateOrCreate(['id' => $model->brand_id],['letter' => mb_substr($model->name, 0, 1, 'UTF-8')]);
}
});
}
}
@@ -0,0 +1,79 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewAlbumModel
*/
class VehicleNewAlbumModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_album';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vehicle_id', 'pic', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewAlbumTranslationModel::class, 'album_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewAlbumTranslationModel::class, 'album_id');
}
const VEHICLE_NEW_ALBUM_FIELDS = [
'pic',
];
const TRANS_FIELDS = [
'alt',
];
}
@@ -0,0 +1,56 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewAlbumTranslationModel
*/
class VehicleNewAlbumTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_album_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'album_id', 'locale', 'alt', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -0,0 +1,80 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewAskedModel
*/
class VehicleNewAskedModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_asked';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vehicle_id', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 相册字段
*/
const VEHICLE_NEW_ASKED_FIELDS = [
'title',
'content',
];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewAskedTranslationModel::class, 'asked_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewAskedTranslationModel::class, 'asked_id');
}
}
@@ -0,0 +1,56 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewAskedTranslationModel
*/
class VehicleNewAskedTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_asked_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'asked_id', 'locale', 'title', 'content', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -0,0 +1,72 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewContentModel
*/
class VehicleNewContentModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_content';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vehicle_id', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewContentTranslationModel::class, 'content_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewContentTranslationModel::class, 'content_id');
}
}
@@ -0,0 +1,56 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewContentTranslationModel
*/
class VehicleNewContentTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_content_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'content_id', 'locale', 'content', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
+121
View File
@@ -0,0 +1,121 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewModel
*/
class VehicleNewModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**x`
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vin', 'brand', 'cover', 'album', 'price', 'type', 'energy', 'model', 'video', 'views', 'created_at', 'updated_at', 'location'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
const TRANS_FIELDS = [
'name', 'condition_desc'
];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewTranslationModel::class, 'vehicle_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewTranslationModel::class, 'vehicle_id');
}
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand');
}
public function models()
{
return $this->belongsTo(ModelModel::class, 'model');
}
public function location()
{
return $this->belongsTo(LocationModel::class, 'location');
}
public function types()
{
return $this->belongsTo(TypesModel::class, 'type', 'id');
}
public function energy()
{
return $this->belongsTo(EnergyModel::class, 'energy', 'id');
}
public function album()
{
return $this->hasMany(VehicleNewAlbumModel::class, 'vehicle_id', 'id');
}
public function asked()
{
return $this->hasMany(VehicleNewAskedModel::class, 'vehicle_id', 'id');
}
public function trait()
{
return $this->hasMany(VehicleNewTraitModel::class, 'vehicle_id', 'id');
}
public function content()
{
return $this->hasMany(VehicleNewContentModel::class, 'vehicle_id', 'id');
}
}
@@ -0,0 +1,72 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewTraitModel
*/
class VehicleNewTraitModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_trait';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vehicle_id', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(VehicleNewTraitTranslationModel::class, 'trait_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleNewTraitTranslationModel::class, 'trait_id');
}
}
@@ -0,0 +1,56 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewTraitTranslationModel
*/
class VehicleNewTraitTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_trait_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'trait_id', 'locale', 'title', 'content', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -0,0 +1,56 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleNewTranslationModel
*/
class VehicleNewTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_vehicle_new_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'vehicle_id', 'locale', 'name', 'condition_desc', 'location', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}