切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
Karson
7 years ago
提交者
GitHub
7 years ago
提交
98e5f32429b6eab7a5399d1f8cdd93dadc376d9e
2 个父辈
d54583e9
36271ab0
Merge pull request #31 from gh81997167/master
严格匹配
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
12 行增加
和
2 行删除
application/admin/command/Menu.php
application/admin/command/Menu.php
查看文件 @
98e5f32
...
...
@@ -25,11 +25,14 @@ class Menu extends Command
->
addOption
(
'controller'
,
'c'
,
Option
::
VALUE_REQUIRED
|
Option
::
VALUE_IS_ARRAY
,
'controller name,use \'all-controller\' when build all menu'
,
null
)
->
addOption
(
'delete'
,
'd'
,
Option
::
VALUE_OPTIONAL
,
'delete the specified menu'
,
''
)
->
addOption
(
'force'
,
'f'
,
Option
::
VALUE_OPTIONAL
,
'force delete menu,without tips'
,
null
)
->
addOption
(
'equal'
,
'e'
,
Option
::
VALUE_OPTIONAL
,
'the controller must be equal'
,
null
)
->
setDescription
(
'Build auth menu from controller'
);
//要执行的controller必须一样,不适用模糊查询
}
protected
function
execute
(
Input
$input
,
Output
$output
)
{
$this
->
model
=
new
AuthRule
();
$adminPath
=
dirname
(
__DIR__
)
.
DS
;
//控制器名
...
...
@@ -40,14 +43,21 @@ class Menu extends Command
$force
=
$input
->
getOption
(
'force'
);
//是否为删除模式
$delete
=
$input
->
getOption
(
'delete'
);
//是否控制器完全匹配
$equal
=
$input
->
getOption
(
'equal'
);
if
(
$delete
)
{
if
(
in_array
(
'all-controller'
,
$controller
))
{
throw
new
Exception
(
"could not delete all menu"
);
}
$ids
=
[];
$list
=
$this
->
model
->
where
(
function
(
$query
)
use
(
$controller
)
{
$list
=
$this
->
model
->
where
(
function
(
$query
)
use
(
$controller
,
$equal
)
{
foreach
(
$controller
as
$index
=>
$item
)
{
$query
->
whereOr
(
'name'
,
'like'
,
strtolower
(
$item
)
.
"%"
);
if
(
$equal
)
$query
->
whereOr
(
'name'
,
'eq'
,
$item
);
else
$query
->
whereOr
(
'name'
,
'like'
,
strtolower
(
$item
)
.
"%"
);
}
})
->
select
();
foreach
(
$list
as
$k
=>
$v
)
{
...
...
请
注册
或
登录
后发表评论