|
@@ -13,7 +13,8 @@ class PlatformSwitch extends Model
|
|
|
* @return int
|
|
|
*/
|
|
|
public static function checkSwitch($user_id,$id,$type){
|
|
|
- return self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->value('id') ? 1:0;
|
|
|
+ $switch_value = self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->value('switch_value');
|
|
|
+ return $switch_value === 0 ? 0 : 1;
|
|
|
}
|
|
|
/**
|
|
|
* @param $user_id
|
|
@@ -22,17 +23,12 @@ class PlatformSwitch extends Model
|
|
|
*/
|
|
|
public static function userSwitch($user_id,$id,$type)
|
|
|
{
|
|
|
- $ret_val = 0;
|
|
|
$check_tags = self::checkSwitch($user_id,$id,$type);
|
|
|
- if($check_tags) {
|
|
|
- self::where(['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type])->delete();
|
|
|
- }else{
|
|
|
- Data::save('PlatformSwitch',
|
|
|
- ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type],'user_id',
|
|
|
- ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type]);
|
|
|
- $ret_val = 1;
|
|
|
- }
|
|
|
- return $ret_val;
|
|
|
+ $switch_value = $check_tags ? 0:1;
|
|
|
+ Data::save('PlatformSwitch',
|
|
|
+ ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type,'switch_value'=>$switch_value],'user_id',
|
|
|
+ ['user_id'=>$user_id,'switch_id'=>$id,'type'=>$type]);
|
|
|
+ return $switch_value;
|
|
|
}
|
|
|
|
|
|
}
|