Shift with red gradient lettering
Loading navigation...

Adopt redirect helpers

Laravel

Refactor your code to use to_action(), to_route(), assertRedirectToRoute(), and assertRedirectToRoute(). These modernize your Laravel applications, as well as streamline compound statements to improve readability.

Before

redirect()->route('post.show', $request->query('id'));
Redirect::action('PostController@show', $id);
 
$response->assertRedirect(route('post.show', $id));
$response->assertRedirect(action('PostController@show', $id));

After

to_route('post.show', $request->query('id'));
to_action('PostController@show', $id);
 
$response->assertRedirectToRoute('post.show', $id);
$response->assertRedirectToAction('PostController@show', $id);

← Back to the Workbench Tasks