1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\admin\model\store;
- use basic\ModelBasic;
- use traits\ModelTrait;
- class StoreProductAttrResult extends ModelBasic
- {
- use ModelTrait;
- protected $insert = ['change_time'];
- protected static function setChangeTimeAttr($value)
- {
- return time();
- }
- protected static function setResultAttr($value)
- {
- return is_array($value) ? json_encode($value) : $value;
- }
- public static function setResult($result,$product_id)
- {
- $result = self::setResultAttr($result);
- $change_time = self::setChangeTimeAttr(0);
- return self::insert(compact('product_id','result','change_time'),true);
- }
- public static function getResult($productId)
- {
- return json_decode(self::where('product_id',$productId)->value('result'),true) ?: [];
- }
- public static function clearResult($productId)
- {
- return self::del($productId);
- }
- }
|