Package Data | |
---|---|
Maintainer Username: | wwardaww |
Maintainer Contact: | aokoruyucu@gmail.com (Ahmet Oğuz Koruyucu) |
Package Create Date: | 2018-02-06 |
Package Last Update: | 2018-02-06 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:20:23 |
Package Statistics | |
---|---|
Total Downloads: | 36 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This Trait Encrypt Your Data (from database or somewhere) or, Decrypt Your data (from client or somewhere) and it doesn't effect your real data (from data source).
Based on samwhisker/laravel-trait-encrypt
composer require wwardaww/laravel-id-cryption
Note : APP_KEY must not be empty in your .env
file.
use Wwardaww\Encryptable;
class YourModel extends Model
{
use Encryptable;
protected $encryptable = [
'id',
'account_id',
'profile_id',
'user_id',
'some_id'
];
protected $hiddenFunctions = [
'someDefaultFunc',
'someDefaultFunc2',
];
|ID |Name | |---------|---------------| |5 |Ahmet Oğuz |
$encryptedId = "eyJpdiI6IlpxVWtpMGt4dERZbkRcL3hXVTZLKzVRPT0iLCJ2YWx1ZSI6IkhUNzF3MEFsRW1cL2tcLzVTRlZ6QmVaZz09IiwibWFjIjoiZTI5M2JiZTRiNzA2NGVjMTIwNmJhNWZjNjA4YmRmY2NlNzIxYTA2MWM3YTI1ZjVlYzQyMWQ5MzIwZDBlYzQ1OSJ9"
$data = YourModel::decryptFind($encrptedId);
$data = YourModel::where('somewhere','data')->get()->toArray();
Array(
[
"id" => "eyJpdiI6IlpxVWtpMGt4dERZbkRcL3hXVTZLKzVRPT0iLCJ2YWx1ZSI6IkhUNzF3MEFsRW1cL2tcLzVTRlZ6QmVaZz09IiwibWFjIjoiZTI5M2JiZTRiNzA2NGVjMTIwNmJhNWZjNjA4YmRmY2NlNzIxYTA2MWM3YTI1ZjVlYzQyMWQ5MzIwZDBlYzQ1OSJ9",
"name" => "Ahmet Oğuz"
]
)
$data->id = 5,
$data->name = "Ahmet Oğuz"
public function someDefaultFunc2(Request $req){
$data = YourModel::where('somewhere','data')->get()->toArray();
...
}
Array(
[
"id" => 5,
"name" => "Ahmet Oğuz"
]
)