laravel/framework — pull request #493 by philsturgeon (2013-03-04 16:11:06+00:00)
Title: Added havingRaw() and orHavingRaw()

I'm not sure if this is the perfect implementation, but it does what I need at the tests are green.

The main cause of my confusion over the implementation is that where and having seem to be built entirely differently. Really the two things should be IDENTICAL in implementation, as the only difference between how they are build is litterally it saying "having" instead of "where".

The only actual difference between the two in MySQL land is that a having works with calculated fields and aliases of stuff that doesn't exist, so having is run on the end result and not run as a criteria for finding relevant rows. That means PHP should treat the two exactly the same and only MySQL cares about the difference.

BUT, what I've done works, so if they're a little different for now under the hood I don't really care. :)