Issue
I have saved some html code in a my database ( using laravel 5.7 , Sqlite ) it saved but after that i want to show it , laravel encodes the special chars.
it have to return as a JSON string to angular without any encoding or changes.
I just want to prevent html special chars encoding.
I have tried this :
$post = Post::find($id);
$content = html_entity_decode($post->content);
return ['content' => $content ];
But it doesn't work
Solution
in your controller
1 $post = Post::find($id);
2 $content =$post->content;
3 return redirect('/your-url')->with(['content'=>$content);
to return json
3. return response()->json($content);
in your blade file (please make sure that your file is saved with file-name.blade.php) you can just output content like thus
{!! $content !!}
Answered By - Emeka Okafor Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.