Laravel 10 to_route() and str() helper function - NEW
Hello Friends,
This tutorial is focused on Laravel 10 to_route() and str() helper function - NEW. we will help you to give example of laravel 10 redirect route from controller example. you can see laravel 10 to_route helper example. if you have question about laravel 10 to_route example then I will give simple example with solution.
Laravel 10 now comes with new str() helper function globally that you can use to do string operations fluently just like how you would do with Str::of.In addition to the str() helper, Laravel 10 also comes with a convenient to_route() helper function that you can use instead of redirect()->route() for named routes for instance.
So let's start with following examples:
Example: str() helper:
OLD Way with Str:
use Illuminate\Support\Str;
$input = 'this is test file.php';
$output = Str::of($input)
->replaceLast('php', 'html')
->camel();
// thisIsTestFile.html
New Way with srt() helper:
$input = 'this is test file.php';
$output = str($input)
->replaceLast('php', 'html')
->camel();
// thisIsTestFile.html
Example: to_route() helper:
OLD Way with Redirect:
Route::get('redirectHome', function() {
return redirect()->route('home');
});
New Way with to_route() helper:
Route::get('redirectHome', function() {
return to_route('home');
});
now it works...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial