gentrobot

Untitled

Dec 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. $header = true;
  2. $file = '/path/to/the/csv/file';
  3. if (($handle = fopen($file, "r")) !== FALSE) {
  4. while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
  5. //skip header row of the csv
  6. if($header){
  7. $header = false;
  8. }else{
  9. $user = \App\User::where('username', $data[0])->first();
  10. if(!empty($user->id)){
  11. $user->password = bcrypt($data[1]);
  12. $user->save();
  13. }
  14. }
  15. }
  16. fclose($handle);
  17. }
Add Comment
Please, Sign In to add comment