1. Go to this page and download the library: Download ajangi/laravel-crypt-model 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/ */
return [
'model_new_attribute_prefix' => 'hashed_',
'aes_secret_key' => env('AES_SECRET_KEY','6818f23eef19d38dad1d272345454549991f6368'), //the secret key you should change
'aes_secret_iv' => env('AES_SECRET_IV','73658734657823465872364587634876523487657'), //the secret iv you should change
];
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use LaravelCryptModel\Models\Concerns\HasHashedPrefixedAttributes;
class User extends Model
{
use HasFactory,Notifiable, HasHashedPrefixedAttributes;
}
use App\Models\User;
$user = User::query()
->where('name','Alireza')
->first();
return json_encode($user);
use App\Models\User;
$user = User::findByPrefixedAttribute('user_id_hashed_7QOG8YaqVQigyD0sYEd25A=='); // the prefixed hashed value we get in step 4
return json_encode($user);
use LaravelCryptModel\PrefixedAttributes;
$user = PrefixedAttributes::findModel('user_id_hashed_7QOG8YaqVQigyD0sYEd25A=='); // the prefixed hashed value we get in step 4
return json_encode($user);