1

I have Request:

public function authorize()
{
    return true;
}

public function rules()
{
    return ['name => 'required'];
}

I called this request on controller in methods store and update. With store method all ok, because method POST. But in method update request is PATCH.

When I call method update, I get error:

Method App\Http\Requests\EsRequest::add does not exist.

How I can fix this?

Routes:

Route::post('/postadd', 'Post\PostController@store')->name('addpost');
Route::patch('/post/update/{id}', 'Post\PostController@update')->name('editpost');

Controller:

public function update(EsRequest $request, $id)
{
    $post = Post::findOrFail($id);
    $request->add(['data' => $request->extra]);
    $post->update($request->all());
    return back();
}
7
  • copy paste the whole PostController.php file here so we can see it and help you accordingly. Commented May 6, 2018 at 11:20
  • this is wrong $request->add(['data' => $request->extra]); Commented May 6, 2018 at 11:23
  • I need add to requrest params.. Commented May 6, 2018 at 11:23
  • But it's already there in the request....when you do the dd($request->all()); that extra should be there also... Commented May 6, 2018 at 11:24
  • In request 2 arrays: data, and extra. I need write to column data dates of the array extra. Commented May 6, 2018 at 11:26

1 Answer 1

1

$request supports collections functions. For adding a new parameter you can simply do:

$request['data'] = ['foo' => 'bar'];

or use collection method as:

$request->put('data', ['foo' => 'bar']);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.