REDIRECTIONS
- A technique for making a web page available under more than one URL address
Redirects
- The simplest method is to use the global redirect helper:
Route::get(‘/dashboard’, function () {
return redirect(‘home/dashboard’);
});
Redirects(contd.)
- Redirecting To Named Routes –
- If your route has parameters, you may pass them as the second argument to the route method: return redirect()->route(‘profile’, [‘id’ => 1]);
Redirects(contd.)
- Redirecting To Controller Actions – You may also generate redirects to controller actions. To do so, pass the controller and action name to the action method:
use App\Http\Controllers\UserController;
return redirect()->action([UserController::class, ‘index’]);
Redirects(contd.)
- Redirecting To External Domains – Sometimes you may need to redirect to a domain outside of your application. You may do so by calling the away method.
return redirect()->away(‘https://www.google.com’);
What is a redirection in Laravel?
- a. A technique for securing web pages
- b. A technique for making a web page available under more than one URL address
- c. A method for defining new routes
- d. A way to filter HTTP requests
What is a redirection in Laravel?
- a. A technique for securing web pages
- b. A technique for making a web page available under more than one URL address
- c. A method for defining new routes
- d. A way to filter HTTP requests
Which Laravel helper function is used for a simple redirection?
- a. route()
- b. redirect()->action()
- c. redirect()->away()
- d. redirect()
Which Laravel helper function is used for a simple redirection?
- a. route()
- b. redirect()->action()
- c. redirect()->away()
- d. redirect()
How do you perform a redirection to a named route in Laravel?
- a. return redirect()->to(‘login’);
- b. return redirect()->route(‘login’);
- c. return redirect(‘login’);
- d. return redirect()->namedRoute(‘login’);
How do you perform a redirection to a named route in Laravel?
- a. return redirect()->to(‘login’);
- b. return redirect()->route(‘login’);
- c. return redirect(‘login’);
- d. return redirect()->namedRoute(‘login’);
When redirecting to a route with parameters in Laravel, how should you pass those parameters?
- a. As a query string in the URL
- b. As an array in the redirect() function
- c. As the second argument to the route() method
- d. As a separate HTTP POST request
When redirecting to a route with parameters in Laravel, how should you pass those parameters?
- a. As a query string in the URL
- b. As an array in the redirect() function
- c. As the second argument to the route() method
- d. As a separate HTTP POST request
What method should you use to perform a redirection to a controller action in Laravel?
- a. return redirect()->controller()
- b. return redirect()->action()
- c. return redirect()->toController()
- d. return redirect()->toAction()
What method should you use to perform a redirection to a controller action in Laravel?
- a. return redirect()->controller()
- b. return redirect()->action()
- c. return redirect()->toController()
- d. return redirect()->toAction()
How can you perform a redirection to an external domain in Laravel?
- a. Use the redirect()->external() method
- b. Use the redirect()->toExternal() method
- c. Use the redirect()->away() method
- d. Use the redirect()->to() method with a full URL
How can you perform a redirection to an external domain in Laravel?
- a. Use the redirect()->external() method
- b. Use the redirect()->toExternal() method
- c. Use the redirect()->away() method
- d. Use the redirect()->to() method with a full URL
[pdf_note link=”https://drive.google.com/file/d/1OkT1qFvG-928r7TOcFUMCMqN3Cv1tEty/view”]