protected function updateProductsFeatures(array $attributes, $products)
    {
        $products->each(function ($item, $key) use ($attributes, $products) {
            $item->update(['features' => json_encode($attributes[$item->id])]);
            $item->save();
        });
    }
protected function updateProductsFeatures(array $attributes, $products)
    {
        $products->each(function ($item, $key) use ($attributes, $products) {
            $item->update(['features' => json_encode($attributes[$item->id])]);
            $item->save();
        });
    }
protected function updateProductsFeatures ( array $ attributes , $ products ) { $ products -> each ( function ( $ item , $ key ) use ( $ attributes , $ products ) { $ item -> update ( [ 'features' => json_encode ( $ attributes [ $ item -> id ] ) ] ) ; $ item -> save ( ) ; } ) ; }
Update the given products features with the passed attributes.

@param  array $attributes
@param  \Illuminate\Database\Eloquent\Collection $products

@return void
Update the given products features with the passed attributes .