public function handle()
 {
     $script = '' . "\n\n";
     $script .= "export function configRouter (router) {\n\n  // normal routes\n  router.map({" . "\n\n";
     foreach ($this->devis->tables()->where('model', '<>', '')->get() as $table) {
         $index = new CreateIndexComponent($this->devis, $table);
         $path = $index->getPath();
         $script .= "\t" . "'/" . $table->name . "/index': { component: require('" . $path . "') }," . "\n";
         $list = new CreateListComponent($this->devis, $table);
         $path = $list->getPath();
         $script .= "\t" . "'/" . $table->name . "': { component: require('" . $path . "') }," . "\n";
         $form = new CreateFormComponent($this->devis, $table);
         $path = $form->getPath();
         $script .= "\t" . "'/" . $table->name . "/create': { component: require('" . $path . "') }," . "\n";
         //   $script.="\t"."'/".$table->name."/:id': { component: require('".$path."') },"."\n";
         $form = new CreateShowComponent($this->devis, $table);
         $path = $form->getPath();
         $script .= "\t" . "'/" . $table->name . "/:" . strtolower(snake_case($table->model)) . '_id/show' . "': { component: require('" . $path . "') }," . "\n";
         //   $script.="\t"."'/".$table->name."/:id': { component: require('".$path."') },"."\n";
         $edit = new CreateEditComponent($this->devis, $table);
         $path = $edit->getPath();
         $script .= "\t" . "'/" . $table->name . "/:" . strtolower(snake_case($table->model)) . '_id' . "': { component: require('" . $path . "') }," . "\n";
         $aaaa = "///////////////ne pas supprimer pour les nested routes//////////" . "\n";
         //   if ($table->name != 'vehicles') {
         //       continue;
         //   }
         /*
         $routes = (new CreateSubRoutes($this->devis, $table))->handle();
         
         foreach ($routes->RouterVue as $route){
             $path = $route['path'];
             if ($route['route'] != '' && $path != '') {
                 $script.="\t".'\''.$route['route'].'\': { component: require(\''.$path.'\') },'."\n";
             }
         }
         */
         $aaaa = "///////////////ne pas supprimer pour les nested routes//////////" . "\n";
         //   $path = $edit->getPath();
         //determine the first level of navigation
         //find the cascade
         //
         /*
                               $hasHasManyRelation = false;
                               if ($table->hasHasManyRelation()) {
                                   $hasHasManyRelation = true;
                               }
                               $hasSpecialVueComponent = false;
                               if ($this->getSpecialVueComponentList($table)) {
                                   $hasSpecialVueComponent = true;
                               }
                               ////
         
                               if (!$hasHasManyRelation && !$hasSpecialVueComponent) { //C
                                   # code...
                               }
         */
         $script .= "\n\n";
     }
     $script .= "\n/*\n    // basic example\n    '/about': {\n      // the component can also be a plain string component id,\n      // but a component with that id must be available in the\n      // App component's scope.\n     // component: require('./components/about.vue')\n    },\n    // nested example\n    '/user/:userId': {\n      component: require('./components/user/index.vue'),\n      subRoutes: {\n        // matches \"/user/:userId/profile/:something\"\n        'profile/:something': {\n          component: require('./components/user/profile.vue')\n        },\n        // matches \"/user/:userId/posts\"\n        'posts': {\n          component: require('./components/user/posts.vue')\n        },\n        // matches \"/user/:userId/settings\"\n        'settings': {\n          component: require('./components/user/settings.vue')\n        }\n      }\n    },\n    // not found handler\n    '*': {\n      //component: require('./components/not-found.vue')\n    },\n    */\n    /*\n    // advanced example\n    '/inbox': {\n      component: require('./components/inbox/index.vue'),\n      subRoutes: {\n        '/message/:messageId': {\n          component: require('./components/inbox/message.vue')\n        },\n        '/archived': {\n          component: require('./components/inbox/archive.vue')\n        },\n        // default component to render into the nested outlet\n        // when the parent route is matched but there's no\n        // nested segment. In this case, \"/inbox\".\n        '/': {\n          // inline component\n          component: {\n            template: 'default yo'\n          }\n        }\n      }\n    }\n    */\n  })\n\n  // redirect\n  router.redirect({\n    '/info': '/about',\n    '/hello/:userId': '/user/:userId'\n  })\n\n  // global before\n  // 3 options:\n  // 1. return a boolean\n  // 2. return a Promise that resolves to a boolean\n  // 3. call transition.next() or transition.abort()\n  /*\n  router.beforeEach((transition) => {\n    if (transition.to.path === '/forbidden') {\n      router.app.authenticating = true\n      setTimeout(() => {\n        router.app.authenticating = false\n        alert('this route is forbidden by a global before hook')\n        transition.abort()\n      }, 3000)\n    } else {\n      transition.next()\n    }\n  })\n  */\n}\n";
     $this->createFile($this->path(), $this->devis->app_name, $script);
 }
 public function constructRouterVue2(Table $from_Table, $chaine_cumul = '', $chaine_edit = '', $chaine_list = '', $loop = 0)
 {
     //var_dump($loop);
     $chaine_cumul .= $from_Table->name . '/';
     $pieces = explode('/', $chaine_cumul);
     end($pieces);
     $avantDernier = prev($pieces);
     $table = Table::where('name', $avantDernier)->first();
     $id = ':id_' . $table->variable;
     echo "<h2>__________________________________________________________________________________________________________________________________________________________</h2>";
     var_dump($pieces);
     $chaine_edit = '';
     foreach ($pieces as $piece) {
         $table = Table::where('name', $piece)->first();
         if ($table) {
             $chaine_edit .= $piece . '/:id_' . $table->variable . '/';
         }
     }
     $chaine_list .= rtrim($chaine_edit, '/:id_' . $from_Table->variable . '/');
     //put thre keys
     // $chaine_edit.=$this->primary().'/';
     // $chaine_cumul.=$this->name.'/';
     foreach ($from_Table->hasHasManyRelationList() as $relation) {
         // var_dump($relation);
         $toTable = Table::find($relation['to_model_id']);
         //var_dump(rtrim($chaine_edit, '/'));
         //var_dump(rtrim($chaine_list, '/'));
         $this->constructRouterVue2($toTable, $chaine_cumul, $chaine_edit, $chaine_list, $loop++);
     }
     //var_dump(rtrim($chaine_edit, '/'));
     $chaine_list = rtrim($chaine_list, '/');
     $chaine_edit = rtrim($chaine_edit, '/');
     var_dump('------------chaine_edit');
     var_dump($chaine_edit);
     /*
             $toComponentTable = strrchr($chaine_list, '/');
             if (!$toComponentTable) {
                 echo ">>";
                 $toComponentTable=$chaine_list;
             }*/
     $toComponentTable = $avantDernier;
     echo "--->";
     var_dump($toComponentTable);
     echo "<---";
     echo "<h2>EDITION</h2>";
     /*
      **  EDITION
      */
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateEditComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         echo "la table {$toComponentTable} non trouvee !!";
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path = '';
         if ($table) {
             $list = new CreateEditComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $edition = $this->RouterVue[] = ['type' => 'edit', 'route' => $chaine_edit, 'to_component' => $toComponentTable, 'path' => $path];
     //var_dump($this->RouterVue);
     var_dump($edition);
     /*
      **  list
      */
     echo "<h2>LIST</h2>";
     //var_dump($chaine_list);
     $route = '';
     var_dump('edition[route]');
     var_dump($edition['route']);
     //$route = strrchr($edition['route'], '/')
     // $route=substr($edition['route'], 0, strpos($edition['route'], '/'));//remove everything after /
     $route = substr($edition['route'], 0, strrpos($edition['route'], '/'));
     //remove everything after /
     //  var_dump('route for list');
     //  var_dump($route);
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateListComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path;
         if ($table) {
             $list = new CreateListComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $list = $this->RouterVue[] = ['type' => 'list', 'route' => $route, 'to_component' => $toComponentTable, 'path' => $path];
     var_dump($list);
     /*
      **  create
      */
     echo "<h2>FORM</h2>";
     $route = $list['route'] . '/create';
     //remove everything after /
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateFormComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path = '';
         if ($table) {
             $list = new CreateFormComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $form = $this->RouterVue[] = ['type' => 'create', 'route' => $route, 'to_component' => $toComponentTable, 'path' => $path];
     var_dump($form);
     /*
             ** Ajout des component specifiques
     
             if ($this->getSpecialVueComponentList($this->table)){
                 foreach ($this->getSpecialVueComponentList($this->table) as $specialView) {
                     $componentName = $this->table->vueComponentName('', $specialView);
                     //$path = $this->table->vueComponentRelativePathTo($this->table, $specialView);
                     $tag = '<'.$this->table->VueTag('',$specialView ).' :'.$this->table->variable.'="object"></'.$this->table->VueTag('',$specialView ).'>';
     
                     //var_dump($editList);
                     //si la fin du liste == model concerné dans le specialcompo
                     //dd($edition['to_component'], $this->table->name);
     
     
     
     
                     // $file =  strrchr($path, '/');
                     // $file = trim($file, '/');
                     // $file = trim($file, '.php');
     
                     //on les execute pour trouver les namespaces
                     $vueClass =  '\Organit\bootstrapping\Vue\MiddlesepcialComponentViews\\'.$this->devis->app_name.'\\'.$specialView;
                 //     dd(
                 //     (new $vueClass($this->devis,$table))->CoreSpecialCompo()->model()
                 //     ,
                 //     (new \Organit\bootstrapping\Vue\MiddlesepcialComponentViews\Middle\BankAccount($this->devis,$table))->CoreSpecialCompo()->model()
                 // );
     
                 //recuperer la liste des table qui on des speciaux compo
                 $list_qq=[];
                 foreach ($this->devis->tables as $_table ) {
                     if ($_table == 'vehicles') {
                         dd($this->getSpecialVueComponentList($_table));
                         # code...
                     }
                     $list_qq[] =  $this->getSpecialVueComponentList($_table);
                 }
                 //dd($list_qq);
                 var_dump('********');
                 var_dump($vueClass);
                     $model = (new $vueClass($this->devis,$this->table))->CoreSpecialCompo()->model();
                     $related_table = Table::where('model', $model)->first();
                     if ($related_table) {
                         //if ($edition['to_component'] == $related_table->name) {
                             $this->RouterVue[]=[
                                 'type' => 'secial',
                                 'route' => $edition['route'].'/get_'.$componentName,
                                 'to_component' => $componentName,
                                 'path' => $edition['path'].'/'.$componentName,
                                 'tag' => $tag
                             ];
                         //}
                         # code...
                     }
     
     
     
     
                 }
             }
     */
     // var_dump(rtrim($chaine_cumul, '/'));
     // if (isset($toTable)) {
     //Table::constructRouterVue($table, $chaine_cumul,  $chaine_edit, $chaine_list, $loop++);
     # code...
     // }
 }