Product::where('is_active', 1)->whereNotIn('category_id', [5])->first();
Or if you want to keep your initial query as well as well as the SQL query you posted
Product::where('code', $product_code[0])
->where('is_active', 1)
->whereNotIn('category_id', [5])
->first();
Of course, the [5] will probably be dynamic, so update the above appropriately.
If you only have one category, you can simply use ->where('category_id', '!=', 5)