extract an if check into a method.
Merge branch '4.0'
Merge branch 'master' of github.com:laravel/framework