NOTE: this is for an endpoint. not for a form request.
let's say I have middleware named Inputs which has this code in the handle()
public function handle(Request $request, Closure $next) {
$data = $request->all();
foreach ($data as $array) {
//HOW TO USE THE CUSTOM RULE HERE?
}
return next($request);
}
here's the custom rule App\Rules
class MyRule {
public function construct() {}
public function passes($attribute, $value) {
if ($value > 1) {
return false;
}
return true;
}
public function message() {
return "data invalid";
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire