品牌信息

This commit is contained in:
2025-05-21 11:28:30 +08:00
parent ff07c5bcd9
commit f8fa2bf3a9
17 changed files with 997 additions and 12 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, 'brand_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleDataTranslationModel::class, 'brand_id');
}
const TRANS_FIELDS = [
'name', 'condition_desc'
];
}
@@ -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', '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', '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 = [
'name', 'condition_desc'
];
}
@@ -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');
}
}
+1 -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'];
/**
* 不允许自动填充模型字段