如何使用自定義的請求驗證,我有一個數組密鑰請求如何使用自定義請求驗證laravel數組?
$request = [
'link_inc_characteristic_id' => $inc_char_id[$i],
'value' => $value[$i],
'created_by' => $created_by,
'last_updated_by' => $last_updated_by,
];
$this->validate($request, [
'value['.$i.']' => 'max:30'
]);
$linkIncCharacteristicValue = LinkIncCharacteristicValue::create($request);
return Response::json($linkIncCharacteristicValue);
[編輯] [CODE增訂] 顯示錯誤:
Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request, array given,
您收到了哪些錯誤? –
驗證不起作用,沒有錯誤.....輸入值自動裁減數據庫字段長度,從驗證沒有錯誤.. – Khoerodin
我只是更新代碼..並得到錯誤 – Khoerodin