36 lines
967 B
PHP
36 lines
967 B
PHP
<?php
|
|
namespace app\model;
|
|
|
|
use think\Model;
|
|
use app\model\ThirdUserAdvertiser;
|
|
|
|
class ThirdUser extends Model
|
|
{
|
|
protected $table = 'bps.bps_third_user';
|
|
// 设置主键
|
|
protected $pk = 'id';
|
|
// 设置自动时间戳
|
|
// protected $autoWriteTimestamp = true;
|
|
|
|
// 定义时间戳字段
|
|
// protected $createTime = 'create_at'; // 创建时间字段
|
|
// protected $updateTime = 'update_at'; // 更新时间字段
|
|
|
|
// 字段类型映射
|
|
protected $casts = [
|
|
// 'id' => 'int',
|
|
];
|
|
|
|
// 与广告主模型的关联
|
|
public function advertisers()
|
|
{
|
|
return $this->hasMany(ThirdUserAdvertiser::class, 'doc_', 'id');
|
|
}
|
|
|
|
// 使用 onBeforeDelete 事件来级联删除广告主记录
|
|
// public static function onBeforeDelete($thirdUser)
|
|
// {
|
|
// // 在删除 ThirdUser 时,删除所有与之关联的 ThirdUserAdvertiser 记录
|
|
// $thirdUser->advertisers()->delete();
|
|
// }
|
|
} |