Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jamesautodude's avatar

jamesautodude wrote a reply+100 XP

5mos ago

Encrypting model data

To anyone coming across this later like I did...

In newest versions, you can just use casts in the model, and put it as "encrypted" like:

protected $casts = [
    'email' => 'encrypted',
    'phone' => 'encrypted',
    'salary' => 'encrypted'
];

And Laravel will handle the encrypting and decrypting all on its own while you just make calls/updates/inserts as normal