1
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
use app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $name 键
|
||||
* @property mixed $value 值
|
||||
*/
|
||||
class Config extends Base
|
||||
{
|
||||
public function setValueAttr($v,$row){
|
||||
log_alert($row);
|
||||
if(is_array($v)){
|
||||
return json_encode($v,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
public function getContentAttr($v,$row){
|
||||
if(in_array($row['type'] ,['radio','checkbox','select','selects'] ) && $row['content']){
|
||||
$firstLetter = substr($row['content'],0,1);
|
||||
if($firstLetter == '[' || $firstLetter == '{'){
|
||||
$arr = json_decode($row['content'],true);
|
||||
}else{
|
||||
$_content = explode("\r\n",$row['content']);
|
||||
$arr = [];
|
||||
foreach($_content as $k1=>$v1){
|
||||
$_v1 = explode('|',$v1);
|
||||
$arr[$_v1[0]]=$_v1[1];
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
public function getValueAttr($v,$row){
|
||||
if(in_array( $row['type'] ,['checkbox','select','selects'])){
|
||||
return json_decode($v,true);
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
public function setSettingAttr($v){
|
||||
if(is_array($v)){
|
||||
return json_encode($v,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
function setRuleAttr($v,$row){
|
||||
if(is_array($v)){
|
||||
return implode(';',$v);
|
||||
}else{
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
function getSettingAttr($v='',$row=[]){
|
||||
if($v){
|
||||
return json_decode($v,true);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
// function setValueAttr($v,$row){
|
||||
// if(is_array($v)){
|
||||
// return implode(',',$v);
|
||||
// }else{
|
||||
// return $v;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user