2022-02-28 10:04:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\model;
|
|
|
|
|
|
|
|
//抽奖模板
|
2022-03-01 08:19:41 +00:00
|
|
|
use think\Model;
|
|
|
|
|
2022-02-28 10:04:28 +00:00
|
|
|
class ActivityTemplate extends Base
|
|
|
|
{
|
|
|
|
|
2022-03-01 08:19:41 +00:00
|
|
|
public function adminType(){
|
|
|
|
return $this->hasOne(ActivityTemplateType::class,"id","type_id")->bind(["type_text"=>"name"]);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 设置内容
|
|
|
|
* */
|
|
|
|
public function setWinnerAttr($value,$data)
|
|
|
|
{
|
|
|
|
$content = array_column($value,null,"sort");
|
|
|
|
$contentKey = array_keys($content);
|
|
|
|
sort($contentKey);
|
|
|
|
$contentData =[];
|
|
|
|
foreach ($contentKey as $ck){
|
|
|
|
$contentData[]= $content[$ck];
|
|
|
|
}
|
|
|
|
return json_encode($contentData,JSON_UNESCAPED_UNICODE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置内容
|
|
|
|
* */
|
|
|
|
public function getWinnerAttr($value,$data)
|
|
|
|
{
|
|
|
|
return json_decode($value,true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function onAfterInsert( $template)
|
|
|
|
{
|
|
|
|
$template->sort = $template->id;
|
|
|
|
$template->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-28 10:04:28 +00:00
|
|
|
}
|