/** * 获取动画关键帧 */ public function getLayerAttrs($attrSel = null) { if ($attrSel) { $datas = ProductLayerAttrModel::where('productid', $this->productid)->where('layerid', $this->id)->where('attrSel', $attrSel)->get(); } else { $datas = ProductLayerAttrModel::where('productid', $this->productid)->where('layerid', $this->id)->get(); } return $datas; }
/** * 关键帧修改 */ public function updateLayerAttr($productid, $layerAttrId) { if (Ajax::ajax()) { $data = Input::all(); if (!$productid || !$data['layerid'] || !$data['con_id'] || !$data['genre'] || !$layerAttrId || !$data['attrSel'] || $data['per'] == '' || $data['val'] == '') { echo json_encode(array('code' => '-1', 'message' => '参数有误!')); exit; } $data = ['productid' => $productid, 'layerid' => $data['layerid'], 'attrSel' => $data['attrSel'], 'per' => $data['per'], 'val' => $data['val']]; ProductLayerAttrModel::where('id', $layerAttrId)->update($data); //判断关键帧是否修改 $layerAttr = ProductLayerAttrModel::find($layerAttrId); if ($layerAttr->attrSel == $data['attrSel'] || $layerAttr->per == $data['per'] || $layerAttr->val == $data['val']) { $isadd = $layerAttr->is_add == 1 ? 2 : $layerAttr->is_add; ProductLayerAttrModel::where('id', $layerAttrId)->update(['record' => 1, 'is_add' => $isadd]); } echo json_encode(array('code' => '0', 'message' => '操作成功!')); exit; } echo json_encode(array('code' => '-2', 'message' => '操作失败!')); exit; }
/** * 获取动画关键帧 */ public function getLayerAttrs($productid, $layerid) { if ($layerid) { $datas = ProductLayerAttrModel::where('productid', $productid)->where('layerid', $layerid)->get(); } else { $datas = ProductLayerAttrModel::where('productid', $productid)->get(); } return $datas; }
/** * 得到修改过的产品的关键帧 */ public function getProLayerAttrs() { $layerAttrs = ProductLayerAttrModel::where('productid', $this->id)->get(); foreach ($layerAttrs as $layerAttr) { if ($layerAttr->record) { $layerAttrRecord[$layerAttr->id] = $layerAttr; } if ($layerAttr->is_add) { $layerAttrAdd[$layerAttr->id] = $layerAttr; } } return array('records' => isset($layerAttrRecord) ? $layerAttrRecord : [], 'adds' => isset($layerAttrAdd) ? $layerAttrAdd : []); }
/** * 查询方法 */ public function query($productid, $layerid) { $datas = ProductLayerAttrModel::where('productid', $productid)->where('layerid', $layerid)->orderBy('id', 'desc')->paginate($this->limit); $datas->limit = $this->limit; return $datas; }
/** * 获取动画关键帧记录 */ public function getLayerAttr($pid, $newpid, $layerArr) { foreach ($layerArr['layerOld'] as $key => $layerOld) { $layerAttrs = ProductLayerAttrModel::where('productid', $pid)->where('layerid', $layerOld)->get(); if (count($layerAttrs)) { foreach ($layerAttrs as $layerAttr) { $data = ['productid' => $newpid, 'layerid' => $layerArr['layerNew'][$key], 'attrSel' => $layerAttr->attrSel, 'per' => $layerAttr->per, 'val' => $layerAttr->val, 'created_at' => time(), 'record' => 0]; ProductLayerAttrModel::create($data); } } } return true; }
/** * 获取动画关键帧 */ public function getLayerAttrs($productid, $layerid) { return ProductLayerAttrModel::where('productid', $productid)->where('layerid', $layerid)->get(); }