The problem has been resolved by adding autoincrement true in the brands model. Thank you for your time.