private function _validateCustom() { // Get Route Info $routeInfo = routeInfo(); // Get Action $routeName = $routeInfo["action"]["as"]; // Detect Custom if (substr($routeInfo["method"], 0, 7) != "custom_") { return null; } // Get For $for = null; // Switch switch ($routeInfo["method"]) { case "custom_index": $for = "list"; break; case "custom_create": $for = "create"; break; case "custom_edit": $for = "edit"; break; case "custom_save": $for = "save"; break; case "custom_update": $for = "update"; break; case "custom_delete": $for = "delete"; break; } // Detect For if ($for) { // Loop Each foreach (GroupItem::hasInterface()->get() as $group) { // Check Valid if ($group->hasValidInterface()) { // Routes $routes = unserialize($group->group_routes); // Get the Value $val = $routes[$for]; // Match if ($val == $routeName) { // Store Custom Group $this->customGroup = $group; // Set Page Data setPageData("group", $this->customGroup); return null; } } } } return Redirect::route("users"); }
<?php /** * Validate Controller Permission */ Event::listen("controller.filter.before", function ($controller) { // Get Permissions Required List $permissions = $controller->permissionRequired(); // Validate if ($permissions) { // Filter Data if (!is_array($permissions)) { $permissions = explode("|", $permissions); } // Get Route Info $routeInfo = routeInfo(); // Check for Exclude if (!$controller->excludeFromPermissions($routeInfo["method"], $permissions)) { // Loop Each Permission foreach ($permissions as $permission) { // Check Permission if (!userHasPermission($permission)) { // Trigger Access Denied Event app("events")->fire("controller.permission.denied", array($this, app())); // Run Access Denied Method return $controller->accessDenied(); break; } } } }