1

I try add data to databese. But have this error.

Illuminate \ Database \ Eloquent \ MassAssignmentException fam

'fam' is a name first argument.

Data dump:

 array:8 [▼
  "fam" => "6"
  "im" => "e"
  "ot" => "r"
  "phone" => "e"
  "log" => "e"
  "pass" => "e"
  "Регистрация" => null
  "_token" => "bEJpcLPYWo5GmhW11Zxs8K0dMmN6anNsvuO0a492"
]

Function code:

  $this->validate($request,[
            'fam'=>'required|max:255',
            'im'=>'required|max:255',
            'ot'=>'required|max:255',
            'log'=>'required|max:255',
            'pass'=>'required|max:255',
            'phone'=>'required|max:255',
            'Регистрацияd'=>'require|max:255'
        ]);
        $data=$request->all();
        dump($data);
        $user=new userModel;
        dump($user);
       $user->fill($data);

User Model dump:

userModel {#192 ▼
  #filable: array:8 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: []
  #guarded: array:1 [▼
    0 => "*"
  ]
}

And model code:

class userModel extends Model
{
    protected $filable=['fam','im','ot','phone','login','pass','reg','token'];

}

You can see the structure of the database here: enter image description here

2
  • It's $fillable. Commented Nov 4, 2017 at 14:23
  • change $filable to $fillable Commented Nov 4, 2017 at 14:23

1 Answer 1

1

Your model has no attributes, and it looks like you have a typo in $fillable

protected $filable=['fam','im','ot','phone','login','pass','reg','token'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.