Skip to main content

Command Palette

Search for a command to run...

Encrypting data with Laravel

Published
1 min read
G

I am a self-taught developer currently in Salt Lake City. Currently, work in Laravel but have experience in plain PHP, PERL, and CakePHP.

Entrepreneurial VP of tech and CTO with a strong grasp of both the business and engineering. PHP developer for 10 years with experience in CakePHP and Laravel

Since Laravel 8.12 encryption is now a part of the model casts. There's no longer any need for traits to encrypt and decrypt.

In Laravel making a field encrypted is as easy as:

class User extends Model
{
    public $casts = [
        'critical_information' => 'encrypted',
    ];
}

Laravel can also handle JSON, arrays, and objects. Check the docs for more information.

More from this blog

Laravel & PHP by Guy Warner

18 posts

Self taught programmer -> Freelancer -> Senior Developer -> CTO

Laravel, PHP and all that comes with it.