Php 从csv导入散列用户密码

Php 从csv导入散列用户密码,php,ajax,laravel,Php,Ajax,Laravel,我需要帮助。我有一个无法解决的大问题,我想在数据库中导入csv文件时哈希所有用户的密码。我的csv文件上传得很好,真的很好用,但密码从不散列。我的代码: UserController.php: Route::post('admin/user_data/store', ['as'=>'users_data_store', 'uses'=>'UserController@users_data_store']); 公共函数用户\数据\存储(){ } 我的模型-User.php: &

我需要帮助。我有一个无法解决的大问题,我想在数据库中导入csv文件时哈希所有用户的密码。我的csv文件上传得很好,真的很好用,但密码从不散列。我的代码:

UserController.php

   Route::post('admin/user_data/store', ['as'=>'users_data_store', 'uses'=>'UserController@users_data_store']);
公共函数用户\数据\存储(){

}

我的模型-User.php

<?php

use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    protected $guarded = ['id', 'created_at'];

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = array('password', 'remember_token');


    public function children()
    {
        return $this->hasMany('User', 'guardian_id');
    }


}
谢谢你的帮助

use Illuminate\Support\Facades\Hash;
超过文件中的代码顶部,然后在插入之前设置哈希密码。使用下面的代码

$areas = csv_to_array($file);
$areas['password'] = Hash::make($areas['password']);
DB::table('users')->insert($areas); 

谢谢你的回复,兄弟,但它是这样显示的:未定义索引:passwordUndefined索引:password??用户密码数组索引名在$areas['index或csv column name'])。我只是向你展示了一个示例。您应该使用$AREA数组的csv列名或密码索引名。这意味着我应该列出所有表用户列以重新放置$AREA??
$areas = csv_to_array($file);
$areas['password'] = Hash::make($areas['password']);
DB::table('users')->insert($areas);