public function store(Request $request, $productid, $layerid)
 {
     $data = $this->getData($request, $productid, $layerid);
     //类样式名称相同自动添加:属性前缀+用户id_+产品id_+随机值
     $data['style_name'] = $this->prefix_attr . $productid . '_' . rand(0, 1000);
     //处理属性样式名称
     $attrModels = $this->getAttrs($productid, $layerid);
     if (count($attrModels) && !$request->name) {
         $data['name'] = $attrModels[0]->name;
     } elseif (!count($attrModels) && $request->name) {
         $data['name'] = $request->name;
     }
     $data['genre'] = $this->getGenre($productid, $layerid);
     $data['created_at'] = time();
     ProductAttrModel::create($data);
     return redirect(DOMAIN . 'admin/' . $productid . '/' . $layerid . '/proAttr');
 }
Esempio n. 2
0
 /**
  * 初始化属性
  */
 public function initAttr($productid, $layerid)
 {
     $data = ['name' => '样式' . $layerid, 'style_name' => $this->prefix_attr . $productid . '_' . rand(0, 10000), 'productid' => $productid, 'layerid' => $layerid, 'padding' => '', 'size' => '720,405', 'pos' => '0,,', 'float' => 0, 'opacity' => '0,0', 'border' => '0,,1,1', 'created_at' => time()];
     $data1 = $data;
     $data2 = $data;
     $data3 = $data;
     $data1['genre'] = 1;
     $data2['genre'] = 2;
     $data3['genre'] = 3;
     ProductAttrModel::create($data1);
     ProductAttrModel::create($data2);
     ProductAttrModel::create($data3);
 }
Esempio n. 3
0
 /**
  * 收集属性数据
  */
 public function getAttrData($pid, $layerid, $genre, $newpid, $layerNewId, $styleName)
 {
     $attrModel = ProductAttrModel::where('productid', $pid)->where('layerid', $layerid)->where('genre', $genre)->first();
     $record = ['padding' => 0, 'size' => 0, 'pos' => 0, 'float' => 0, 'opacity' => 0, 'border' => 0];
     $data = ['name' => $attrModel->name, 'style_name' => $styleName, 'productid' => $newpid, 'layerid' => $layerNewId, 'genre' => $genre, 'padding' => $attrModel->padding, 'size' => $attrModel->size, 'pos' => $attrModel->pos, 'float' => $attrModel->float, 'opacity' => $attrModel->opacity, 'border' => $attrModel->border, 'created_at' => time(), 'record' => serialize($record)];
     ProductAttrModel::create($data);
 }