Thursday, February 8, 2018

Laravel 5.5 Update Post not working - development

Laravel 5.5 Update Post not working

edit.nlade :

{!! Form::model($post, array('method'=>'PATCH','url'=>'/posts/{post}'.$post->id))  !!}





<label for="title">Titolo</label>

<input type="text" class="form-control" id="title" name="title" value="">

<label for="body">Corpo</label>

<textarea id="body" name="body" class="form-control" value="">

      </textarea>

web.php:

Route::get(‘/’, ‘PostsController@index’)->name(‘home’);

Route::get(‘/posts/create’, ‘PostsController@create’);

Route::post(‘/posts’, ‘PostsController@store’);

Route::get(‘/posts/{post}’, ‘PostsController@show’);

Route::get(‘/posts/tags/{tag}’, ‘TagsController@index’);

Route::post(‘/posts/{post}/comments’,’CommentsController@store’);

Route::get(‘/posts/{id}/edit’, ‘PostsController@edit’);

Route::get(‘/edit/{post}’, ‘PostsController@update’);

Route::patch(‘/post/{post}’, ‘PostsController@update’);

Route::get(‘/register’, ‘RegistrationController@create’);

Route::post(‘/register’, ‘RegistrationController@store’);

Route::get(‘/login’, ‘SessionsController@create’);

Route::post(‘/login’, ‘SessionsController@store’);

Route::get(‘/logout’, ‘SessionsController@destroy’);

postcontroller:

public function edit( Post $post )

{

    return view('posts.edit', compact('post'));

}


public function update(Request $request, Post $post){

    Post::where('id', $post)->update($request->all());

    return redirect('/home');

}



from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-5-5-update-post-not-working/
via Lzo Media

No comments:

Post a Comment