corrected laravel function