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
ee580351
Commit
ee580351
authored
May 13, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
b2cd81d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
MakeModelCommand.php
src/Command/MakeModelCommand.php
+6
-5
seeder.stub
src/Command/stubs/seeder.stub
+1
-1
No files found.
src/Command/MakeModelCommand.php
View file @
ee580351
...
...
@@ -6,11 +6,11 @@ namespace Meibuyu\Micro\Command;
use
Hyperf\Command\Annotation\Command
;
use
Hyperf\Command\Command
as
HyperfCommand
;
use
Hyperf\Contract\ContainerInterface
;
use
Hyperf\Database\ConnectionResolverInterface
;
use
Hyperf\Database\Schema\MySqlBuilder
;
use
Hyperf\DbConnection\Db
;
use
Hyperf\Utils\Str
;
use
Psr\Container\ContainerInterface
;
use
Symfony\Component\Console\Input\InputArgument
;
use
Symfony\Component\Console\Input\InputOption
;
...
...
@@ -678,7 +678,7 @@ class MakeModelCommand extends HyperfCommand
$content
.=
"
\n\t\t
Router::delete('/
{
id
}
', 'App\Controller
\\
"
.
$modelClass
.
"Controller@delete');"
;
if
(
$routes
)
{
foreach
(
$routes
as
$v
)
{
$content
.=
"
\n\t\t
Router::get('/
$
r
/\{id\}', 'App\Controller
\\
"
.
$modelClass
.
"Controller@
$v
');"
;
$content
.=
"
\n\t\t
Router::get('/
$
v
/\{id\}', 'App\Controller
\\
"
.
$modelClass
.
"Controller@
$v
');"
;
}
}
$content
.=
"
\n\t
});"
;
...
...
@@ -721,7 +721,7 @@ class MakeModelCommand extends HyperfCommand
$rs
=
[];
$required
=
"nullable"
;
if
(
$null
!==
'YES'
)
{
if
(
$default
!==
''
)
{
if
(
$default
!==
''
&&
$default
!==
'0'
&&
!
$default
)
{
$required
=
"required"
;
$messages
[]
=
"
\t\t
'
{
$name
}
.
{
$required
}
' => '
{
$msgName
}
不能为空!'"
;
}
...
...
@@ -872,7 +872,8 @@ class MakeModelCommand extends HyperfCommand
$n
=
((
isset
(
$length
[
0
])
&&
$length
[
0
]
&&
$length
[
0
]
<
$maxNumber
)
?
$length
[
0
]
:
$maxNumber
);
$n
=
rand
(
1
,
$n
);
$n2
=
((
isset
(
$length
[
1
])
&&
$length
[
1
]
<
$maxNumber
)
?
$length
[
1
]
:
2
);
$fields
[]
=
"
\t\t\t\t
'
{
$name
}
' =>
\$
faker->randomFloat(
$n
,
$n2
),"
;
$n3
=
$n2
+
20
;
$fields
[]
=
"
\t\t\t\t
'
{
$name
}
' =>
\$
faker->randomFloat(
$n
,
$n2
,
$n3
),"
;
break
;
case
"char"
:
case
"varchar"
:
...
...
@@ -1136,7 +1137,7 @@ class MakeModelCommand extends HyperfCommand
if
(
$null
==
'YES'
)
{
$t
.=
"->nullable()"
;
}
if
(
$default
!==
'
'
)
{
if
(
(
$default
&&
$default
!==
''
)
||
$default
===
'0
'
)
{
$t
.=
"->default('
$default
')"
;
}
if
(
$collation
)
{
...
...
src/Command/stubs/seeder.stub
View file @
ee580351
...
...
@@ -17,7 +17,7 @@ class %className% extends Seeder
public
function
run
()
{
$faker
=
Factory
::
create
(
'zh-CN'
);
%
modelClass
%::
truncate
();
%
modelClass
%::
query
()
->
truncate
();
$n
=
%
generateCount
%
;
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
$instance
=
%
modelClass
%::
create
([
...
...
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