问题描述:

Is it possible to fill a guarded field with the ::create method from Elequent models,

If my User model is like so:

$guarded=['password','id']

$fillable=['username']

Is it possible to do this?

User::create(['username'=>'mynewusername','password'=hash::make($password)])

网友答案:

No - you cannot do that.

But you could do this

$user = User::create(['username'=>'mynewusername']);
$user->password = Hash::make($password);
$user->save();
相关阅读:
Top