语法错误,意外' firstOrCreate' (T_STRING),期望变量(T_VARIABLE)或' $

时间:2016-12-29 13:59:05

标签: laravel laravel-5 laravel-5.2

我尝试这样做时出现此错误:

[{
   "id": "1",
   "item_request_id": "1",
   "nama_detail": "Create Login Novell"
}, {
   "id": "2",
   "item_request_id": "1",
   "nama_detail": "Create Email Baru"
}, {
   "id": "3",
   "item_request_id": "1",
   "nama_detail": "Disable / Hapus Login Novell"
}, {
   "id": "4",
   "item_request_id": "1",
   "nama_detail": "Disable / Hapus Email"
}]

$ additional_features是一个数组,我尝试添加它,所以我在数组中有多少项目我将有那么多记录。任何建议?

1 个答案:

答案 0 :(得分:3)

使用正确的语法:

$additional = Feature::firstOrCreate($data);

或者:

$additional = new Feature;
$additional->firstOrCreate($data);