Skip to content

Commit

Permalink
升级addons
Browse files Browse the repository at this point in the history
  • Loading branch information
funadmin committed Nov 23, 2021
1 parent 1e18bc5 commit a86ee43
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions vendor/funadmin/fun-addons/src/curd/service/CurdService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ protected function setArg()
$this->joinModel = $this->config['joinModel']?:$this->joinTable ;
$this->joinMethod = $this->config['joinMethod'];
$this->joinForeignKey = $this->config['joinForeignKey'] ;
if(count( $this->joinForeignKey)==1 && strpos($this->joinForeignKey[0],',')){
$this->joinForeignKey = array_filter(explode(',',( $this->joinForeignKey[0])));
}
$this->joinPrimaryKey = $this->config['joinPrimaryKey'] ;
if(count( $this->joinPrimaryKey)==1 && strpos($this->joinPrimaryKey[0],',')){
$this->joinPrimaryKey = array_filter(explode(',',( $this->joinPrimaryKey[0])));
}
$this->selectFields = $this->config['selectFields'];
$controllerStr = $this->config['controller'] ?: Str::studly($this->table);
$controllerArr = explode('/', $controllerStr);
Expand Down Expand Up @@ -416,13 +422,14 @@ protected function makeModel()
foreach ($this->joinTable as $k=>$v){
if(isset($this->joinMethod[$k])){
$method = $this->joinMethod[$k];
list($joinPrimaryKey,$joinForeignKey)=array($this->joinPrimaryKey[$k],$this->joinForeignKey[$k]);
}else{
$method = 'hasOne';
list($this->joinPrimaryKey[$k],$this->joinForeignKey[$k])=array($this->joinForeignKey[$k],$this->joinPrimaryKey[$k]);
list($joinPrimaryKey,$joinForeignKey)=array($this->joinForeignKey[$k],$this->joinPrimaryKey[$k]);
}
$joinTpl = $this->tplPath . 'join.tpl';
$joinTplStr .= str_replace(['{{$joinName}}','{{$joinMethod}}', '{{$joinModel}}', '{{$joinForeignKey}}', '{{$joinPrimaryKey}}'],
[lcfirst(Str::studly($v)),$method, ucfirst(Str::studly($this->joinModel[$k])), $this->joinForeignKey[$k], $this->joinPrimaryKey[$k]],
[lcfirst(Str::studly($v)),$method, ucfirst(Str::studly($this->joinModel[$k])),$joinForeignKey, $joinPrimaryKey],
file_get_contents($joinTpl)).PHP_EOL;
}
}
Expand Down Expand Up @@ -479,7 +486,6 @@ protected function makeModel()
// 创建模板
protected function makeView()
{
;
$formFieldData = $this->getFormData();
$indexViewTpl = $this->tplPath .'view' . DS . 'index.tpl';
$indexViewTpl = str_replace(['{{$nodeType}}','{{$script}}'],[$this->nodeType,$this->script], file_get_contents($indexViewTpl));
Expand Down

0 comments on commit a86ee43

Please sign in to comment.