PHP code example of richardstyles / eloquent-aes

1. Go to this page and download the library: Download richardstyles/eloquent-aes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

richardstyles / eloquent-aes example snippets




namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use RichardStyles\EloquentAES\EloquentAESFacade;

class User extends Model
{
    /**
     * The attributes that should be encrypted.
     *
     * @var array
     */
    protected $casts = [
        'ssn' => 'encrypted',
        'credit_card' => 'encrypted',
        'address' => 'encrypted:array',
        'preferences' => 'encrypted:collection',
        'metadata' => 'encrypted:object',
    ];

    /**
     * Get the encrypter instance that should be used to encrypt attributes.
     */
    public static function encryptUsing()
    {
        return EloquentAESFacade::getFacadeRoot();
    }
}
bash
php artisan vendor:publish --provider="RichardStyles\EloquentAES\EloquentAESServiceProvider" --tag="config"
bash
php artisan key:eloquent