'Laravel redirect
I'm preparing a laravel test in a school, and there's a question about i'm not sure. Let's suppose this:
action("UsersController@getProfile", [$user->id]);
The question is:
What is the benefit of using the following call to action() in your code? Available answers are:
- This code directly calls the getProfile() method.
- We can change the URL for the profile page without having to change this code.
- action() redirects to the user’s profile page.
- We can render the user profile in the current page.
- We automatically protect the user profile from XSS attacks.
I think correct answer is 3) but I'm not sure about exactly why. Can you help me?
Solution 1:[1]
As per the documentation, the action() helper generates a URL.
It won't redirect the user to the given URL though. Perhaps the 3) answer is misleading.
So the correct answer would be 2) because you can indeed change the URL nomenclature in your routes definition without having to worry about where it is used in the views.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rachids |
