State machines for PHP classes and Eloquent models