Guy Warner
Laravel & PHP by Guy Warner

Laravel & PHP by Guy Warner

Encrypting data with Laravel

Guy Warner's photo
Guy Warner
·Feb 20, 2022·

1 min read

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.

 
Share this