I am using Laravel 5.4 and the encrypt/decrypt methods in my controller to protect user data.
I get an error when the $p-content is not encrypted. I would like users to selected weather they want to have their content encrypted or not. Which means I'll need to detect the content or add another column to my database with this choice. Ideally, I would like to simply check the content to see if it is encrypted or not.
public function index()
{
$posts = Post::orderBy('id', 'desc')->get();
foreach ($posts as $p) {
**$p->content = decrypt($p->content);**
}
return view('posts.index', ['posts' => $posts]);
}