Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Pragma/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ public function resources($pattern, $controller = null, $callback = [], $ctrl_bu
}
call_user_func_array([is_object($controller) ? $controller : new $controller(), 'delete'], $route->getValues());
})->alias("$prefix-delete");

$this->patch("/:$pname/field/:field", function($id, $field) use($controller, $ctrl_builder) {
$route = $this->getCurrentRoute();
$controller = ! is_null($controller) ? $controller : ( is_callable($ctrl_builder) ? call_user_func_array($ctrl_builder, $route->getValues()) : null );
if( ! is_null($controller) && ! method_exists($controller, 'toggle') ) {
Router::halt(404, 'Resource not found');
}
call_user_func_array([is_object($controller) ? $controller : new $controller(), 'toggle'], $route->getValues());
})->alias("$prefix-toggle");
});
}

Expand Down