mardi 29 août 2017

Bcrypt Password when uploading file excel into database in Laravel 5.4

Hello i have a problem with importing excel to the database, i need to bcrypt my password. For now i already can successfully import my excel to database, but my password still in plain text. Here is my code :

 public function importExcel()
  {
    if(Input::hasFile('import_file')){
      $path = Input::file('import_file')->getRealPath();
      $data = Excel::load($path, function($reader) {
      })->get();
      if(!empty($data) && $data->count()){
        foreach ($data as $key => $value) {
          $insert[] =
          [
            'name'=>$value->name,
            'password'=>$value->password,
            'email'=>$value->email,
            'id_branch'=>$value->id_branch,
            'birth_date'=>$value->birth_date,
            'birth_location'=>$value->birth_location,
            'sex'=>$value->sex,
            'job'=>$value->job,
            'address'=>$value->address,
            'telephone'=>$value->telephone,
            'handphone'=>$value->handphone,
            'office_address'=>$value->office_address
          ];
        }
        if(!empty($insert)){
          $value['password'] = bcrypt($value['password']);
          DB::table('member')->insert($insert);
          return redirect('admin/'.$this->path . '/')->with('success','Success Add New Record');
        }
      }
    }
    return back();
  }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wF5NDx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire