/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //install modules by loading controllers into modules table $controllersDirContent = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('../app/Http/Controllers'), \RecursiveIteratorIterator::SELF_FIRST); foreach ($controllersDirContent as $key => $val) { if (!preg_match('#\\\\.{0,2}$#', $key) && preg_match('#\\.php$#', $key)) { $name = explode('Controllers\\', $key)[1]; if (Module::where('name', $name)->first() === null) { Module::create(["name" => $name]); } } } $roles = Role::all(); return view('admin.roles.index', compact('roles')); }