78 lines
1.5 KiB
PHP
78 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\console\model;
|
|
|
|
use support\Model;
|
|
|
|
/**
|
|
* VehicleNewAttributeCategoriesModel
|
|
*/
|
|
class VehicleNewAttributeCategoriesModel 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_attribute_categories';
|
|
|
|
/**
|
|
* 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', 'category_name', 'sort_order', 'created_at'];
|
|
|
|
/**
|
|
* 不允许自动填充模型字段
|
|
*/
|
|
protected $guarded = [];
|
|
|
|
|
|
/**
|
|
* 单条翻译
|
|
*/
|
|
public function translation()
|
|
{
|
|
return $this->hasOne(VehicleNewAttributeCategoriesTranslationModel::class, 'categories_id')->where('locale', locale());
|
|
}
|
|
|
|
/**
|
|
* 多条翻译
|
|
*/
|
|
public function translations()
|
|
{
|
|
return $this->hasMany(VehicleNewAttributeCategoriesTranslationModel::class, 'categories_id');
|
|
}
|
|
|
|
public function attribute()
|
|
{
|
|
return $this->hasMany(VehicleNewAttributesModel::class, 'category_id', 'id');
|
|
}
|
|
} |