Skip to content
Advertisement

Laravel $requst->all() method returns an empty array

JavaScript

this.request('post', `${controller_url}/update/${id}/${this.updated_row.title}/${this.updated_row.description}`)

Route:

Route::post('/categories/update/{id}/{title}/{description}', 'CategoryController@update');

Controller:

public function update( Request $request, $id, $title, $description)
{
    var_dump($id);
    dd($request->all());
}

Result:

string(2) "81"
[]

I am wondering why $request->all() returns an empty array while var_dump($id) returns a value?

Advertisement

Answer

id is coming as a URL not as a query params or request body. Your route is reading it in the URL. If you pass it as a ?id=81 you will get it.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement