Refactoring to use Illuminate database