'int', 'product_id' => 'int', 'num' => 'int' ]; protected $fillable = [ 'auth_user_id', 'product_id', 'num' ]; public function product() { return $this->belongsTo(Product::class); } public function user() { return $this->belongsTo('App\User','auth_user_id'); } public function auth_user() { return $this->belongsTo('App\User','auth_user_id'); } public static function getNotShowProductIDs($user_id){ $ret = []; $ProductBuys = ProductBuy::where('auth_user_id', $user_id)->get(); if($ProductBuys){ foreach($ProductBuys as $ProductBuy){ if($ProductBuy->product){ if($ProductBuy->product->max_buy && $ProductBuy->num >= $ProductBuy->product->max_buy_num){ $ret[] = $ProductBuy->product->id; } } } } return $ret; } }