Home > database >  Trying to get property of non-object
Trying to get property of non-object

Time:12-21

im getting "Trying to get property 'selleruserid' of non-object" this error. How can i resolve this error?

$selleruserid= 0;


$featured['items'] = Items::with('Ratings')->select('items.item_id', 'items.user_id AS selleruserid', 'items.item_liked','items.item_slug','items.item_preview','items.item_name','items.item_type','users.user_photo','users.username','users.user_document_verified','items.updated_item','items.item_sold','items.free_download','items.item_flash','items.item_type_cat_id','items.regular_price','items.item_token', 'items.mainpage_boost_last')->leftjoin('users', 'users.id', '=', 'items.user_id')->where('items.item_status','=',1)->where('items.mainpage_boost_last','>', $today_date)->where('items.drop_status','=','no')->orderBy(DB::raw('RAND()'))->take($setting['setting']->home_featured_items)->get();


$selleruserid = $featured->selleruserid; // ERROR LINE


$checkuser = Items::checkuser($selleruserid);

I will be glad if you help me thank you

CodePudding user response:

Based on your assignment, the line: $selleruserid = $featured->selleruserid;

Should be: $selleruserid = $featured['items']->selleruserid;

If you still have the same error, then Items::with('Ratings')->... isn't returning anything.

  • Related