Skip to content
Advertisement

Laravel 5.8, CRUD when editing image didn’t show up (blade)?

I try to create edit blade to get old value from database. the title successfully appears, but the image and body (textarea) didn’t appears, here is some code of my edit.blade.php

JavaScript

And here is my contoller connect to edit.blade.php

JavaScript

Can anyone help me, how to show image the right way in edit.blade.php

Advertisement

Answer

For this line of your code please change as follow:

From:

JavaScript

To:

JavaScript

Then add the following function to your Post model:

JavaScript

Then use the function in your view like this if that image exist it will return the location if not exist it will return the null.

JavaScript

If you get issue with this function just update the public_path() . '/imgberita/' inside the function, hope you get idea.

For textare you can use the old() function in your view:

JavaScript

For example like this:

JavaScript

But remember we use the old('body') function when we use the validate() and we pass the data from controller by using ->withInput() like this:

JavaScript

Also you can directly pass data in your edit.blade.php by using with($request) function.

If your body is null you will get error then use the {{$post->body ?? ''}}.

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