1

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)])
jww
  • 97,681
  • 90
  • 411
  • 885
user3620691
  • 69
  • 1
  • 7

1 Answers1

1

No - you cannot do that.

But you could do this

$user = User::create(['username'=>'mynewusername']);
$user->password = Hash::make($password);
$user->save();
Laurence
  • 58,936
  • 21
  • 171
  • 212