He could do it as follows
Cut the bar of size 31 into segments of size 16|8|4|2|1
Clearly this can be achieved with just four cuts.
Then, for each day $n$, ensure the worker leaves with the gold bars which correspond to 1 in the binary representation of $n$.
For example, on day 21, the binary representation is 10101 so the worker must leave with the gold bars of size 16, 4 and 1.
This means that the worker will sometimes have to swap previous bars they've earnt. For example, on day 2, the worker will give back the gold bar of size 1 and receive the gold bar of size 2.