我正在爲我的api編寫更新方法。我需要更新請求的字段。 因此,我試圖只獲取請求的字段並更新它們。但是,即使您將$ fill填充到字符串,下面的代碼也會返回null。
foreach ($fillableFields as $fill){
$customerId->$fill = $request->get("$fill") ;
編輯 - 1
我的代碼是像下面;
$fillableFields = array('lastname','firstname');
當我dd($ fill)它返回我null。
你能告訴我們的'輸出$ fillableFields','$ customerId'和'$ request'請好嗎? –
剛剛更新了我的問題 – Gvep
以及如何定義$ customerId? –