Skip to content

Instantly share code, notes, and snippets.

@emurmotol
Last active July 20, 2016 15:12
Show Gist options
  • Save emurmotol/81b7dc880f64cf730dd32bbcf4c45dd6 to your computer and use it in GitHub Desktop.
Save emurmotol/81b7dc880f64cf730dd32bbcf4c45dd6 to your computer and use it in GitHub Desktop.
// So here goes my code
public static function cardholdersJson() {
$path = resource_path('assets/json/cardholders.json');
$collection = collect(json_decode(file_get_contents($path), true));
$cardholders = $collection->map(function($cardholder) {
return ['password' => bcrypt($cardholder['password'])]; // I need to hash each of the password
});
return $cardholders->all(); // before I return this
}
// I have this json as cardholders.json
// [
// {
// "id": "12345678910",
// "name": "Maria Magdalena",
// "email": "[email protected]",
// "password": "123qwe",
// "phone_number": "09261123415"
// },
// {
// "id": "01987654321",
// "name": "Juan Masipag",
// "email": "[email protected]",
// "password": "123qwe",
// "phone_number": "09261231315"
// }
// ]
// And I need to get this output (hashed password)
// array:2 [▼
// 0 => array:5 [▼
// "id" => "12345678910"
// "name" => "Maria Magdalena"
// "email" => "[email protected]"
// "password" => "$2y$10$g6GW0BIg8wJlBzRI5tfyh.AI0r7pjEcO9OxyOZGPMuEuHx6PsOKoO"
// "phone_number" => "09261123415"
// ]
// 1 => array:5 [▼
// "id" => "01987654321"
// "name" => "Juan Masipag"
// "email" => "[email protected]"
// "password" => "$2y$10$NEKTgbYI5aN7T5ytZE1pXuzj/RbMtTTBJ6PUcJ/FRD/MZB0epZkEq"
// "phone_number" => "09261231315"
// ]
// ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment