Facing 302 Found error when trying to update using a post
method in a route.
Route
Route::post('update_article/{id}', 'ArticleController@update_article')->name('articles.update');
Edit Form Blade
{!! Form::model($article, ['route'=>['articles.update', $article->id], 'method' => 'post', 'class' => 'form-horizontal form-stripe']) !!}
Controller
public function update_article(Request $request, $id)
{
$data = Article::find($id);
$data->title = $request->input('title');
$data->description = $request->input('description');
$data->user_id = Auth::id();
$data->status = $request->input('status');
$data->save();
return redirect()->route('articles.index');
}
Using POST
for updating instead of PUT
as i am using summernote. When i use PUT
, large description
gets truncated. In summernote it states that it may happen if i do not use POST
method.
And there is also a default route just before the update_article
route for articles resources as:
Route::resource('articles', 'ArticleController');
Note: csrf token
is sent as _token
params in the post operation. Cannot find any solution yet. Is there anything I am missing?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire