validate($rules); foreach ($rules as $k => $v) { $data[$k] = Arr::get($validated, $k); } return $data; } public function ok($data = null) { return [ "code" => 200, "data" => $data, ]; } public function error(string $msg) { return [ "code" => 400, "error" => $msg, ]; } }