添加数据我有这样的功能:无法从请求与laravel
public function store(Requests\OfferRequest $request)
{
$offer = new Offer($request->all());
Auth::user()->offer()->save($offer);
$maxoffer = Maxoffer::where('article_id', $request->input('article_id'))
->where('start', $request->input('start'))->get();
if($maxoffer == null)
{
Auth::user()->maxoffer()->create($request->all());
}
else
{
if($maxoffer->price < $request->input('price'))
{
$newOffer = Auth::user()->maxoffer()
->where('id', $maxoffer->id)
->update(['price'=>$request->input('price')]);
}
}
Alert::success('Offer is succesfully added!', 'Good job!')->persistent("Close");
return Redirect::back();
}
,但因为我得到这个我不能添加数据:
ErrorException在OffersController.php线63: undefined property: 照亮\ Database \ Eloquent \ Collection :: $价格 OffersController.php第63行HandleExceptions-> handleError('8', '未定义的属性:Illuminate \ Database \ Eloquent \ Collection :: $ price', 'C:\ wamp \ www \ bidbook \ app \ Htt p \控制器\ OffersController.php”, '63', 阵列( '请求'=>对象(OfferRequest), '提供'=>对象(优惠), 'maxoffer'=>对象(集合)))在OffersController .PHP线63
这里有什么问题?
什么结果DD($ maxoffer)? – paranoid
null .......................但为什么,错在哪里:$ maxoffer = Maxoffer :: where('article_id',$ request-> input ( 'article_id的')) - >在哪里( '开始',$请求 - >输入( '开始')) - >获得(); – MonkeyBusiness
以及结果dd($ request-> all()); – paranoid