My code like this :
public function functionA(Request $request)
{
...
if($request->get('data')) {
//echo '<pre>';print_r($request->get('data'));echo '</pre>';die();
$data = json_decode($request->get('data'), true);
$data = collect($data['data']);
$this->validate($data, [
'id'=>'required|numeric',
'quantity'=>'required|numeric',
]);
$input = $data->only('id', 'quantity','request_date');
...
}
}
The result of echo '<pre>';print_r($request->get('data'));echo '</pre>';die();
like this :
{"data":{"id":46,"quantity":1,"total":100000,"information":"chelsea","name":"Hazard","request_date":"14-08-2017 16:26:00"},"expired":"2017-08-14T06:27:00.738Z"}
If the code executed, there exist error like this :
Type error: Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request,...
How can I solve the error?