Example #1
0
 function store(Request $request)
 {
     $this->validate($request, ['route_name' => 'max:255|required|string|unique:routes,route_name']);
     $route = new \App\Route();
     $route->route_name = $request->route_name;
     $route->save();
     return response()->json($route);
 }
Example #2
0
 function map($args, $http_method)
 {
     if (empty($args) || count($args) != 2) {
         throw new Exception('error param');
     }
     $pattern = array_shift($args);
     $callback = array_pop($args);
     $route = new \App\Route();
     $route->setPattern($pattern);
     $route->setCallback($callback);
     $route->setHttpMethod($http_method);
     $hash = md5($route->getPattern() . $route->getHttpMethod());
     $this->_routes[$hash] = $route;
 }