/** * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(Request $request) { $this->validate($request, array('method' => 'required', 'path' => 'required', 'action_name' => 'required|unique:routes')); $attributes = $request->all(); Audit::log(Auth::user()->id, trans('admin/routes/general.audit-log.category'), trans('admin/routes/general.audit-log.msg-store', ['name' => $attributes['name']])); $this->route->create($attributes); Flash::success(trans('admin/routes/general.status.created')); return redirect('/admin/routes'); }
/** * @return \Illuminate\View\View */ public function load() { $AppRoutes = \Route::getRoutes(); $cnt = 0; foreach ($AppRoutes as $appRoute) { $name = $appRoute->getName(); $methods = $appRoute->getMethods(); $path = $appRoute->getPath(); $actionName = $appRoute->getActionName(); if (!str_contains($actionName, 'AuthController') && !str_contains($actionName, 'PasswordController')) { foreach ($methods as $method) { $route = null; if ('HEAD' !== $method && !starts_with($path, '_debugbar')) { // TODO: Use Repository 'findWhere' when its fixed!! // $route = $this->route->findWhere([ // 'method' => $method, // 'action_name' => $actionName, // ])->first(); $route = \App\Models\Route::ofMethod($method)->ofActionName($actionName)->ofPath($path)->first(); if (!isset($route)) { $cnt++; $newRoute = $this->route->create(['name' => $name, 'method' => $method, 'path' => $path, 'action_name' => $actionName]); } } } } } Flash::success(trans('admin/routes/general.status.loaded', ['number' => $cnt])); return redirect('/admin/routes'); }