Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $header = true;
- $file = '/path/to/the/csv/file';
- if (($handle = fopen($file, "r")) !== FALSE) {
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
- //skip header row of the csv
- if($header){
- $header = false;
- }else{
- $user = \App\User::where('username', $data[0])->first();
- if(!empty($user->id)){
- $user->password = bcrypt($data[1]);
- $user->save();
- }
- }
- }
- fclose($handle);
- }
Add Comment
Please, Sign In to add comment