Esempio n. 1
0
 public function getPropertiesAttribute()
 {
     $categoryProperties = CategoryProperty::select('id', 'category_id', 'name', 'type')->where('category_id', $this->category_id)->get()->toArray();
     foreach ($categoryProperties as $k => &$v) {
         $v['values'] = GoodsCategoryProperty::select('id', 'value')->where('goods_id', $this->id)->where('category_property_id', $v['id'])->get()->toArray();
     }
     return $categoryProperties;
 }
Esempio n. 2
0
 public function property_update(Request $requests, $id)
 {
     $params = $requests->all();
     $categoryProperty = CategoryProperty::find($id);
     if ($categoryProperty == null) {
         $ret['meta']['code'] = 0;
         $ret['meta']['error'] = '目标不存在';
     } else {
         $categoryProperty->name = $params['name'];
         $categoryProperty->type = $params['type'];
         $categoryProperty->save();
         $ret['meta']['code'] = 1;
     }
     echo json_encode($ret);
 }