Editing a Post – WordPress-Like Blog Laravel 5.7 and AdminLTE 3 (13)

WordPress-Like Blog Laravel 5.7 and AdminLTE 3 (13) – Editing a Post

In this thirteenth part of creating WordPress-Like Blog using Laravel 5.7 and AdminLTE 3, we will :

  1. Edit an Existing Post

Edit an Existing Post

Jump over to the Backend\BlogController.php and create edit() method.

Create a new file inside resource/views/backend/blog directory and name it form.blade.php. We will move some lines from create.blade.php to this new file.

Modify create.blade.php inside this section :

Cut and paste the code between {!! Form::model !!}} and {!! Form::close() !!} to form.blade.php

We will cut and paste the script section at the bottom of create.blade.php to new file script.blade.php :

And change the script part on create.blade.php to the following :

Create edit.blade.php, the content is only slightly different with create.blade.php, take note to some differences in the Form attribute :

Now, if you open your backend post index page and click the edit button, you will be redirected to the edit post page :

Membuat Blog dengan Laravel 5.7 dan AdminLTE 3 (13) – Mengedit Post

Modify form.blade.php to display the image if the post has already uploaded an image :

Next thing we have to do is to modify the Backend\BlogController.php and add the update() method, previously let’s modify PostRequest.php inside App\Http\Requests :

Now let’s add the update() method inside BlogController.php

Now if you update the post, the post will be successfully updated.

Github commit.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.