PHP code example of quantumwebco / laravel-db-encryption
1. Go to this page and download the library: Download quantumwebco/laravel-db-encryption 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/ */
quantumwebco / laravel-db-encryption example snippets
use Quantumweb\DBEncryption\Traits\EncryptedAttributes;
class User extends Eloquent {
use EncryptedAttributes;
/**
* The attributes that should be encrypted on save.
*
* @var array
*/
protected $encryptable = [
'first_name', 'last_name'
];
}
namespace App\Http\Controllers;
use App\User;
class UsersController extends Controller {
public function index(Request $request)
{
$user = User::whereEncrypted('first_name','john')
->orWhereEncrypted('last_name','!=','Doe')->firstOrFail();
return $user;
}
}