Well, the question is just how realistically you want to implement it.
If you want a relatively simple way to implement it, then simplifying physical laws regarding B-fields could work just fine.
HOWEVER, if you want a realistic magnet, it will be really really hard to code.
I could try working stuff out with you, but be aware that it could end up feeling relatively similar to newtonian gravity, since those two are very similar to each other.