Changed some code to Laravel syntax