My code to validate data like this :
public function register(Request $request)
{
//echo '<pre>';print_r($request->all());echo '</pre>';die();
$this->validate($request, [
'email'=>'required',
'password'=>'required',
'data_cache.dataCache.id'=>'required|numeric'
'data_cache.dataCache.quantity'=>'required|numeric'
]);
}
The result of echo '<pre>';print_r($request->all());echo '</pre>';die();
like this :
Array
(
[data_cache] => {"dataCache":{"id":112,"quantity":1,"information":"stamford bridge","request_date":"15-08-2017 02:30:00"},"expired":"2017-08-14T16:30:26.272Z"}
[email] => chelsea@gmail.com
[password] => 87654321
)
The data_cache is json data
On the view blade, I add this to display the message validation :
@if ($errors->has('data_cache'))
<span class="help-block">
<strong>{{ $errors->first('data_cache') }}</strong>
</span>
@endif
If the code executed, there is no display message validation
Seems the validation json data is still wrong
How can I do it correctly?