如何在Laravel中的User :: create()中输入自定义变量?

时间:2017-04-17 00:38:42

标签: laravel variables hash passwords

$user = User::create(request(['name', 'email', 'password']));

在上面的代码中,我需要用什么语法来替换带有自定义$ password变量的request() - >密码变量?

1 个答案:

答案 0 :(得分:1)

最快的方法是:

$vars = request(['name','email']);
$vars['password'] = $password;
$user = User::create($vars);