public static function constructRouterVue____________________old(Table $table, $chaine_cumul = '', $chaine_list = '', $chaine_edit = '', $loop = 0) { var_dump($table->RouterVue); var_dump($loop); $chaine_cumul .= $table->name . '/'; $chaine_list = str_replace('/', '/id/', $chaine_cumul); $chaine_edit = rtrim($chaine_list, '/id/'); //put thre keys // $chaine_list.=$table->primary().'/'; // $chaine_cumul.=$table->name.'/'; foreach ($table->hasHasManyRelationList() as $relation) { // var_dump($relation); $toTable = Table::find($relation['to_model_id']); //var_dump(rtrim($chaine_list, '/')); //var_dump(rtrim($chaine_edit, '/')); Table::constructRouterVue($toTable, $chaine_cumul, $chaine_list, $chaine_edit, $loop++); } var_dump(rtrim($chaine_list, '/')); $table->RouterVue->push(['type' => 'list', 'route' => rtrim($chaine_list, '/')]); var_dump(rtrim($chaine_edit, '/')); $table->RouterVue[] = ['type' => 'list', 'route' => rtrim($chaine_list, '/')]; // var_dump(rtrim($chaine_cumul, '/')); // if (isset($toTable)) { //Table::constructRouterVue($table, $chaine_cumul, $chaine_list, $chaine_edit, $loop++); # code... // } }
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... // } }