Tell me how to transfer the variable to the route through the route?
Route::post('/addCat', 'addOperationController@addCategory'); Here is the call to the controller method. You need to pass a variable to this method.
Variables are transferred to the controller via routes with the help of parameters ( see the documentation ), which are indicated in curly brackets
Route::get('/addCat/{cat_name}', 'addOperationController@addCategory'); The addCategory method addCategory should be:
public function addCategory($cat_name) { // при наборе адреса site.ru/addCat/test переменная $cat_name // примет значение test } If you pass the value through the form POST method for the route
Route::get('/addCat', 'addOperationController@addCategory'); then your controller should look like this:
public function addCategory(Request $request) { // Здесь поле с именем cat_name можно будет получить так: // $request->cat_name } Here is a link to the related documentation.
Source: https://ru.stackoverflow.com/questions/826295/
All Articles