作者:
gpmm (銀色)
2023-06-01 22:33:35※ 引述《stayfool (fool)》之銘言:
: 程式如下
: $flight = new Product;
: $flight->name = "iphone";//此行出錯
: $flight->save();
: 錯誤訊息 count(): Argument #1 ($value) must be of type Countable|array
: $flight->name = "iphone"
: 改成 $flight->name = ["iphone"]
: 改成 $flight->name = (array)["iphone"]
: 都會得到相同的錯誤訊息,請問正確的語法?
Product 是你的 Model 嗎?
因為從三行程式碼中看不出來 count 是在哪裡被呼叫了,
是否 Product 當中有其他的 setter / getter / mutator / cast 呢?
可以的話把 Product Model 一起提供會更容易找到問題喔 :)