我尝试将数据添加到数据库。但是有这个错误。
Illuminate \ Database \ Eloquent \ MassAssignmentException fam
' FAM'是名字的第一个论点。
数据转储:
array:8 [▼
"fam" => "6"
"im" => "e"
"ot" => "r"
"phone" => "e"
"log" => "e"
"pass" => "e"
"Регистрация" => null
"_token" => "bEJpcLPYWo5GmhW11Zxs8K0dMmN6anNsvuO0a492"
]
功能代码:
$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);
用户模型转储:
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 => "*"
]
}
模型代码:
class userModel extends Model
{
protected $filable=['fam','im','ot','phone','login','pass','reg','token'];
}
您可以在此处查看数据库的结构: enter image description here
答案 0 :(得分:1)
您的模型没有属性,看起来您在$ fillable中有拼写错误
protected $filable=['fam','im','ot','phone','login','pass','reg','token'];