Commit 57b30643 authored by 梁俊杰's avatar 梁俊杰

生成关系优化

parent 89827af0
...@@ -377,7 +377,7 @@ class MakeModelCommand extends HyperfCommand ...@@ -377,7 +377,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\t/**\n\t* 属于" . $v['relation_model_name'] . "的关联\n\t*/"; $relation .= "\n\t/**\n\t* 属于" . $v['relation_model_name'] . "的关联\n\t*/";
$relation .= "\n\tpublic function " . $v['function'] . "()"; $relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{"; $relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->belongsTo(' . $v['relation_model_name'] . "::class,'" . $v['local_table_key'] . "','{$v['relation_table_key']}' );"; $relation .= "\n\t\t" . 'return $this->belongsTo(' . $v['relation_model_name'] . "::class);";
$relation .= "\n\t}"; $relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . " $" . $v['function'] . "\n"; $properties .= " * @property " . $v['relation_model_name'] . " $" . $v['function'] . "\n";
} }
...@@ -390,7 +390,7 @@ class MakeModelCommand extends HyperfCommand ...@@ -390,7 +390,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\tpublic function " . $v['function'] . "()"; $relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{"; $relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->belongsToMany(' . $v['relation_model_name'] . "::class,'" $relation .= "\n\t\t" . 'return $this->belongsToMany(' . $v['relation_model_name'] . "::class,'"
. $v['relation_table'] . "','{$v['constraint_table_key']}','{$v['local_table_key']}');"; . $v['relation_table'] . "');";
$relation .= "\n\t}"; $relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n"; $properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n";
} }
...@@ -402,7 +402,7 @@ class MakeModelCommand extends HyperfCommand ...@@ -402,7 +402,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\t**/"; $relation .= "\n\t**/";
$relation .= "\n\tpublic function " . $v['function'] . "()"; $relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{"; $relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->hasMany(' . $v['relation_model_name'] . "::class,'" . $v['relation_table_key'] . "','" . $v['local_table_key'] . "' );"; $relation .= "\n\t\t" . 'return $this->hasMany(' . $v['relation_model_name'] . "::class);";
$relation .= "\n\t}"; $relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n"; $properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment