getTableStub()))->replace([ $this->table, $this->search, $this->api, $this->paginate, $this->useList, $this->tree ], [ $this->getTableContent(), $this->getSearchContent(), $this->apiString, $this->getPaginateStubContent(), $this->getUseList(), $this->getTreeProps() ])->toString(); } /** * get file * * @return string */ public function getFile(): string { // TODO: Implement getFile() method. return CatchAdmin::makeDir(CatchAdmin::getModuleViewsPath($this->module).Str::of($this->controller)->replace('Controller', '')->lcfirst()).DIRECTORY_SEPARATOR.'index.vue'; } /** * get search content * * @return string */ protected function getSearchContent(): string { $search = Str::of(''); $formComponents = $this->formComponents(); foreach ($this->structures as $structure) { if ($structure['label'] && $structure['form_component'] && $structure['search']) { if (isset($formComponents[$structure['form_component']])) { $search = $search->append( Str::of($formComponents[$structure['form_component']]) ->replace( [$this->label, $this->prop, $this->modelValue], [$structure['label'], $structure['field'], sprintf('query.%s', $structure['field'])] ) ); } } } return $search->trim(PHP_EOL)->toString(); } /** * get list content; * * @return string */ protected function getTableContent(): string { $tableColumn = <<
HTML; $table = Str::of(''); foreach ($this->structures as $structure) { if ($structure['field'] && $structure['label'] && $structure['list']) { $table = $table->append( Str::of($tableColumn)->replace([$this->label, $this->prop], [$structure['label'], $structure['field']]) )->newLine(); } } return $table->trim(PHP_EOL)->toString(); } /** * form components * * @return array */ protected function formComponents(): array { $components = []; foreach (File::glob( $this->getFormItemStub() ) as $stub) { $components[File::name($stub)] = File::get($stub); } return $components; } /** * get formItem stub * * @return string */ protected function getFormItemStub(): string { return dirname(__DIR__).DIRECTORY_SEPARATOR.'stubs' .DIRECTORY_SEPARATOR.'vue'.DIRECTORY_SEPARATOR .'formItems'.DIRECTORY_SEPARATOR.'*.stub'; } /** * get table stub * * @return string */ protected function getTableStub(): string { return dirname(__DIR__).DIRECTORY_SEPARATOR.'stubs' .DIRECTORY_SEPARATOR.'vue'.DIRECTORY_SEPARATOR.'table.stub'; } /** * get paginate stub content * * @return string */ protected function getPaginateStubContent(): string { return $this->hasPaginate ? '