/** * data list * @return view */ public function index() { $type_id = (int) $_GET['type_id']; $attr_type = [0 => '唯一属性', 1 => '单选属性']; $list = Attribute::where('type_id', $type_id)->paginate(config('shop.pagesize')); return view('admin.attribute.index', compact('list', 'type_id', 'attr_type')); }
public function index($slug) { $category = Category::findBySlug($slug); $sizes = array_flatten(Attribute::where("attr", "Shoe Size")->first()->attributeoptions()->select('option_name')->get()->toArray()); $parts = scandir(public_path() . "/Frontend/shoes/" . $category->folder); $parts = array_diff($parts, array('.', '..')); $savedList = User::find(Session::get('user')->id)->savedlist; //print_r($savedList); return view(Config('constants.frontView') . '.design', compact('category', 'parts', 'sizes', 'savedList')); }
/** * -------------------------------------------------------- * ajax属性列表 * -------------------------------------------------------- */ public function ajaxList(Request $request, $typeId, $goodsId = 0) { if ($request->ajax()) { if ($goodsId && Goods::find($goodsId)) { $type = GoodsType::find($typeId); $attrs = Attribute::where('type_id', $type->id)->get(); $goods = Goods::find($goodsId); $goodsAttrs = $goods->goodsAttrs; foreach ($attrs as $v) { $v->attr_value = unserialize($v->attr_value); $v->list = GoodsAttr::where(['attr_id' => $v['id'], 'goods_id' => $goodsId])->select('attr_value', 'attr_price')->get(); //[['attr_value'=>'', 'attr_price'=>''],...]; if (!$v->list->first()) { $v->list = [['attr_value' => '', 'attr_price' => 0]]; } } //dump($attrs); /************************ $goods = Goods::find($goodsId); $goodsAttrs = $goods->goodsAttrs; foreach($goodsAttrs as $v){ $attr = Attribute::find($v['attr_id']); $v->attr_value_list = unserialize($attr->attr_value); $v->attr_name = $attr->attr_name; $v->attr_type = $attr->attr_type; $v->attr_input_type = $attr->attr_input_type; } //$goodsAttrs = GoodsAttr::where(['goods_id'=>$goodsId])->select('id', 'attr_id', 'attr_value as _value', 'attr_price')->get()->toArray(); ******************************/ return response()->json($attrs); } else { $attrs = []; $type = GoodsType::find($typeId); $attrs = Attribute::where('type_id', $type->id)->get(); //属性值去序列化 foreach ($attrs as $attr) { $attr->attr_value = unserialize($attr->attr_value); } return response()->json($attrs); } } else { $attrs = ['error']; return response()->json($attrs); } }
/** * delete data * @return json */ public function delete() { $id = (int) $_POST['id']; DB::beginTransaction(); $rs1 = Type::destroy($id); if (!$rs1) { DB::rollback(); } $attr = DB::select('select * from it_attributes where type_id = ?', [$id]); if ($attr) { $rs2 = Attribute::where('type_id', $id)->delete(); if (!$rs2) { DB::rollback(); } } DB::commit(); if ($rs1) { return response()->json(array('status' => 200, 'message' => 'Deleted Successfully')); } else { return response()->json(array('status' => 400, 'message' => 'Delete Failure')); } }
public function getCarinfo() { $user = Auth::user(); $attributes = Attribute::where('spec', '=', 'file_upload') ->where('active', '=', 1) ->get(); $carSet = Car::where('uid', '=', $user->id) ->where('active', '=', 1) ->orderBy('last_used', 'desc') ->orderBy('created_at', 'desc') ->get(); $cars = array(); foreach ($carSet as $car) { array_push($cars, $car); } $data = [ 'car_hand' => 'one', 'good_attribs' => $attributes, 'cars' => $cars, 'carActive' => true, 'profile' => true, 'wTitle' => '个人中心 - 车辆信息' ]; return view('profile/carInfo', $data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($id) { $attr = Attribute::where('cat_id', '=', $id)->get(); return view("admin.attribute.index", ['data' => $attr]); }