f(-1) = (-1)^3 - (-1)*7 - 6 = -1 + 7 - 6 = 0

Hence f(x) = (x+1)(x^2 + ax - 6)

Expand this out

f(x) = x^3 + ax^2 - 6x + x^2 + ax - 6

= x^3 + (a+1)x^2 + (a-6)x -6

By comparing co-efficients

a + 1 = 0

a - 6 = -7

a = -1

Thus

f(x) = (x + 1)(x^2 - x - 6)

= (x + 1)(x - 3)(x + 2)