DEV Community

El Morjani Mohamed
El Morjani Mohamed

Posted on • Edited on

Laravel Tip💡: Extract Validated Input Elegantly

We often redirect our users to specific routes using the "redirect()" method. Did you know there is a shorter and more expressive method called "to_route"? 🚀

<?php

// 🚀 Instead of this
return redirect()->route('profile');

// ✨ You can do this
return to_route('profile');
?>
Enter fullscreen mode Exit fullscreen mode

Both snippets achieve the same result, but to_route makes your code cleaner and more readable. Small changes can have a big impact! 😊

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay