This code was allegedly written by senior developer. It is taken from Laravel Daily channel https://www.youtube.com/watch?v=9t79PDqXjok
P.S. Tests have been added to cover all existing functionality
git clone https://github.com/divigrupa/refactor-senior-code.git .
composer install
php artisan test