Answer the question
In order to leave comments, you need to log in
Which is better to use for Route::get, or is it more common to pass data to a controller in Laravel?
I'm here in my thoughts, what should I use more often?
To submit a registration form with data and at login, etc. without options, only the form and the POST method , but such links as moving to pages, output, deletion, etc. whether it is worth collecting such data with a POST request and processing it. For example, such a situation, I have a lot of fields in the table, they are deleted by clicking on the button, a link is formed, where jQuery collects all the fields selected by the checkboxes, data, creating a dynamic link. To do this, you need to use this form of input to get the ID of the fields to be deleted:
<input type="checkbox" class="checkbox" name="check_row[]" value="{{$user->id}}">
<input type="checkbox" class="checkbox" name="check_row[{{$user->id}}]" >
Answer the question
In order to leave comments, you need to log in
Unclear question. In the first case, you are passing $user->id as the value for the check_row[ field; in the second, you are not passing any value for the check_row[$user->id] field.
If this is, for example, a list of users and you mark with checkboxes who to delete, then it is more logical to use the first option.
The second option is applicable if, for example, you have a list of users and you need to set different values for all, for example:
check_row[1][is_manager]
check_row[1][salary]
...
check_row[2][is_manager]
check_row[2][salary]
...
The rule is very simple - displaying data - GET, changing data - ONLY POST.
Moving through pages is a display, so GET is needed, at the same time it allows you to save the state in the link.
Deleting data is a change, so it's a POST, and we don't have a stateful link that accidentally deletes everything by going to. Google somehow experimented with preloading pages when reading emails and cleaned up a couple of stores that sent letters tied to GET for admins.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question