Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-micro
Commits
d84666cc
Commit
d84666cc
authored
May 08, 2020
by
梁俊杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关联关系方法使用蛇形形式编写
parent
3db122d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
MakeModelCommand.php
src/Command/MakeModelCommand.php
+5
-3
No files found.
src/Command/MakeModelCommand.php
View file @
d84666cc
...
...
@@ -668,7 +668,8 @@ class MakeModelCommand extends HyperfCommand
}
if
(
isset
(
$info
[
'relations'
][
'hasMany'
]))
{
foreach
(
$info
[
'relations'
][
'hasMany'
]
as
$v
)
{
$rs
.=
"
\n\t
public function
{
$v
[
'function'
]
}
(
\$
id): array
\n
"
;
$f
=
Str
::
camel
(
$v
[
'function'
]);
$rs
.=
"
\n\t
public function
{
$f
}
(
\$
id): array
\n
"
;
$rs
.=
"
\t
{\n"
;
$rs
.=
"
\t\t\$
pageSize = (int)
\$
this->request->input('page_size', DEFAULT_PAGE_SIZE);
\n
"
;
$rs
.=
"
\t\t
return
\$
this->find(
\$
id)->
{
$v
[
'function'
]
}
()->orderByDesc('id')->paginate(
\$
pageSize)->toArray();
\n
"
;
...
...
@@ -737,15 +738,16 @@ class MakeModelCommand extends HyperfCommand
if
(
isset
(
$info
[
'relations'
])
&&
$info
[
'relations'
])
{
if
(
isset
(
$info
[
'relations'
][
'hasMany'
]))
{
foreach
(
$info
[
'relations'
][
'hasMany'
]
as
$v
)
{
$f
=
Str
::
camel
(
$v
[
'function'
]);
$rs
.=
"
\n\t
/**"
;
$rs
.=
"
\n\t
* 获取
{
$v
[
'relation_model_name'
]
}
关联列表数据"
;
$rs
.=
"
\n\t
* @Perm(
\"
index
\"
)"
;
$rs
.=
"
\n\t
* @param;
\$
id id编号"
;
$rs
.=
"
\n\t
* @return mixed"
;
$rs
.=
"
\n\t
*/"
;
$rs
.=
"
\n\t
public function
{
$
v
[
'function'
]
}
(
\$
id)
\n
"
;
$rs
.=
"
\n\t
public function
{
$
f
}
(
\$
id)
\n
"
;
$rs
.=
"
\t
{\n"
;
$rs
.=
"
\t\t\$
data =
\$
this->repository->
show
(
\$
id);
\n
"
;
$rs
.=
"
\t\t\$
data =
\$
this->repository->
{
$f
}
(
\$
id);
\n
"
;
$rs
.=
"
\t\t
return success('获取成功',
\$
data);
\n
"
;
$rs
.=
"
\t
}
\n
"
;
$routes
[]
=
$v
[
'function'
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment