public function editDemand($id) { $demand = Demand::findOrFail($id); $cattree = $this->InitClassSelectOption(0, $demand->category_id); $cates = Category::where('parent_id', '=', 0)->orderby('id', 'desc')->get(); $user = User::whereRaw('id=' . $demand->user_id)->get()->first(); $brands = Brand::where("cateid", '=', $demand->category_id)->orderBy('id', 'desc')->get(); // var_dump($brands);exit(); $dc = new DemandController(); $bidinfo = $bidinfo = $dc->getbidinfo($demand); $deli = delivery::whereRaw('deid=' . $demand->id)->get()->first(); $data = array('demand' => $demand, 'cates' => $cates, 'user' => $user, 'bids' => $bidinfo['bids'], 'bidinfo' => $bidinfo, 'deli' => $deli, 'catetree' => $cattree, 'brands' => $brands); return view("admin.edemand")->with($data); }
public function getbidinfo($demand) { $bids = $demand->bids; $data = array(); $data['demand'] = $demand; $data['bids'] = $bids; //所有的出价信息 $myBid = null; $lowprice = 9999999; $firstbidtime = strtotime("now"); $data['winbid'] = null; $data['firstbid'] = null; $data['lowbid'] = null; $data['winuser'] = null; $data['lowprice'] = $lowprice; foreach ($bids as $bid) { if ($bid->is_win == 1) { $data['winbid'] = $bid; } if (strtotime($bid->created_at) < $firstbidtime) { $data['firstbidtime'] = $bid->created_at; $data['firstbid'] = $bid; } if ($bid->price < $lowprice) { $lowprice = $bid->price; $data['lowprice'] = $lowprice; $data['lowbid'] = $bid; } } if ($data['winbid'] != null) { $userid = $data['winbid']->user_id; $winuser = User::whereRaw("id=" . $userid)->get()->first(); $data['winuser'] = $winuser; } return $data; }