Skip to content

Commit d964c7d

Browse files
committed
container to resolve
1 parent a00c901 commit d964c7d

11 files changed

Lines changed: 74 additions & 177 deletions

src/App/Http/Controllers/Api/MainController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MainController extends Controller
1616
public function __construct(Menu $MenuPro)
1717
{
1818
$this->menuModel = $MenuPro;
19-
$this->builderMain = resolve('builderAdminMain'); //全局统一实例
19+
$this->builderMain = resolve('builderMain')->event('adminMain'); //全局统一实例
2020
}
2121
public function index()
2222
{

src/App/Http/Controllers/Api/MenuController.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace CoreCMF\Admin\App\Http\Controllers\Api;
44

55
use Illuminate\Http\Request;
6-
use Illuminate\Container\Container;
76
use App\Http\Controllers\Controller;
87

98
use CoreCMF\Admin\App\Models\Menu;
@@ -14,13 +13,11 @@ class MenuController extends Controller
1413
/** @var MenuRepository */
1514
private $menuModel;
1615
private $configModel;
17-
private $container;
1816

19-
public function __construct(Container $container, Menu $menuRepo, Config $configRepo)
17+
public function __construct(Menu $menuRepo, Config $configRepo)
2018
{
2119
$this->menuModel = $menuRepo;
2220
$this->configModel = $configRepo;
23-
$this->container = $container;
2421
}
2522
/**
2623
* [index 表格列表显示]
@@ -33,12 +30,12 @@ public function __construct(Container $container, Menu $menuRepo, Config $config
3330
public function index(Request $request)
3431
{
3532
$pageSizes = $this->configModel->getPageSizes();
36-
$data = $this->container->make('builderModel')
33+
$data = resolve('builderModel')
3734
->request($request)
3835
->group('admin')
3936
->pageSize($this->configModel->getPageSize())
4037
->getData($this->menuModel);
41-
$table = $this->container->make('builderTable')
38+
$table = resolve('builderTable')
4239
->tabs($this->configModel->tabsGroupList('MENU_GROUP_LIST'))
4340
->data($data['model'])
4441
->column(['prop' => 'id', 'label'=> 'ID', 'width'=> '55'])
@@ -61,10 +58,6 @@ public function index(Request $request)
6158
->searchTitle('请输入搜索内容')
6259
->searchSelect(['id'=>'ID','title'=>'标题','api_route'=>'API路由名'])
6360
;
64-
$html = $this->container->make('builderHtml')
65-
->title('配置管理')
66-
->item($table)
67-
->response();
68-
return $html;
61+
return resolve('builderHtml')->title('配置管理')->item($table)->response();
6962
}
7063
}

src/App/Http/Controllers/Api/NavController.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Auth;
66
use Illuminate\Http\Request;
7-
use Illuminate\Container\Container;
87
use App\Http\Controllers\Controller;
98

109
use CoreCMF\Admin\App\Models\Menu;
@@ -13,23 +12,21 @@ class NavController extends Controller
1312
{
1413
private $builderMain;
1514
private $menuModel;
16-
private $container;
1715
private $name;
1816
/** return CoreCMF\Core\Builder\Main */
19-
public function __construct(Menu $MenuPro, Container $container)
17+
public function __construct(Menu $MenuPro)
2018
{
2119
$this->menuModel = $MenuPro;
22-
$this->container = $container;
23-
$this->builderMain = $this->container->make('builderAdminMain')->event('adminMain'); //全局统一实例
20+
$this->builderMain = resolve('builderMain'); //全局统一实例
2421
$this->name = config('admin.topNav.name');
2522
}
2623
public function top()
2724
{
2825
$topNav = config('admin.topNav');
2926
// sidebar apiUrl 地址
3027
$topNav['apiUrl'] = route('api.admin.nav.sidebar');
31-
$this->builderMain->topNav($topNav);
32-
return $this->container->make('builderHtml')->main($this->builderMain)->response();
28+
$this->builderMain->topNav($topNav)->event('adminTop');
29+
return resolve('builderHtml')->main($this->builderMain)->response();
3330
}
3431
public function sidebar()
3532
{
@@ -44,7 +41,7 @@ public function sidebar()
4441
return $value;
4542
}
4643
});
47-
$this->builderMain->menus($menus);
48-
return $this->container->make('builderHtml')->main($this->builderMain)->response();
44+
$this->builderMain->menus($menus)->event('adminSidebar');
45+
return resolve('builderHtml')->main($this->builderMain)->response();
4946
}
5047
}

src/App/Http/Controllers/Api/PackageController.php

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace CoreCMF\Admin\App\Http\Controllers\Api;
44

55
use Illuminate\Http\Request;
6-
use Illuminate\Container\Container;
76

87
use App\Http\Controllers\Controller;
98
use CoreCMF\Core\Http\Models\Package;
@@ -16,29 +15,22 @@ class PackageController extends Controller
1615
/** @var userRepo */
1716
private $packageModel;
1817
private $configModel;
19-
private $container;
2018
private $rules;
2119

22-
public function __construct(
23-
Package $packageRepo,
24-
Config $configRepo,
25-
Container $container,
26-
ModelRules $rules
27-
)
28-
{
20+
public function __construct(Package $packageRepo,Config $configRepo,ModelRules $rules)
21+
{
2922
$this->packageModel = $packageRepo;
3023
$this->configModel = $configRepo;
31-
$this->container = $container;
3224
$this->rules = $rules;
3325
}
3426
public function index(Request $request)
3527
{
3628
$pageSizes = $this->configModel->getPageSizes();
37-
$data = $this->container->make('builderModel')
29+
$data = resolve('builderModel')
3830
->request($request)
3931
->pageSize($this->configModel->getPageSize())
4032
->getData($this->packageModel);
41-
$table = $this->container->make('builderTable')
33+
$table = resolve('builderTable')
4234
->event('adminPackage')
4335
->data($data['model'])
4436

@@ -62,11 +54,7 @@ public function index(Request $request)
6254
->searchTitle('请输入搜索内容')
6355
->searchSelect(['id'=>'ID','name'=>'标识','title'=>'名称','author'=>'作者'])
6456
;
65-
$html = $this->container->make('builderHtml')
66-
->title('扩展包管理')
67-
->item($table)
68-
->response();
69-
return $html;
57+
return resolve('builderHtml')->title('扩展包管理')->item($table)->response();
7058
}
7159
/**
7260
* [status description]
@@ -87,19 +75,15 @@ public function status(Request $request){
8775
* [add 安装扩展包]
8876
*/
8977
public function add(){
90-
$form = $this->container->make('builderForm')
78+
$form = resolve('builderForm')
9179
->item(['name' => 'composer', 'type' => 'textarea', 'label' => 'composer下载', 'placeholder' => '请输入url,通过composer下载并且保证服务器已经安装composer服务。'])
9280
->item(['name' => 'namespace', 'type' => 'text', 'label' => '扩展包命名空间', 'placeholder' => '命名空间,例: CoreCMF\Socialite\ 。一般在composer.json里面有配置,autoload.psr-4的值.' ])
9381
->rules($this->rules->add())
9482
->apiUrl('submit',route('api.admin.app.package.store'))
9583
->config('labelWidth','150px')
9684
->config('formSubmit',['name'=>'安装','style'=> ['width'=>'25%']])
9785
;
98-
return $this->container->make('builderHtml')
99-
->title('安装扩展包')
100-
->item($form)
101-
->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])
102-
->response();
86+
return resolve('builderHtml')->title('安装扩展包')->item($form)->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])->response();
10387
}
10488
/**
10589
* [store 启用禁用扩展包]
@@ -110,9 +94,7 @@ public function add(){
11094
public function store(Request $request,packageManage $packageManage)
11195
{
11296
$message = $packageManage->namespaceInstall($request->namespace);
113-
return $this->container->make('builderHtml')
114-
->message($message)
115-
->response();
97+
return resolve('builderHtml')->message($message)->response();
11698
}
11799
/**
118100
* [delete 卸载展包]
@@ -130,6 +112,6 @@ public function delete(Request $request,packageManage $packageManage)
130112
'message' => '后台配置数据删除成功!',
131113
'type' => 'success',
132114
];
133-
return response()->json(['message' => $message], 200);
115+
return resolve('builderHtml')->message($message)->response();
134116
}
135117
}

src/App/Http/Controllers/Api/PermissionController.php

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace CoreCMF\Admin\App\Http\Controllers\Api;
44

55
use Illuminate\Http\Request;
6-
use Illuminate\Container\Container;
76
use App\Http\Controllers\Controller;
87

98
use CoreCMF\Core\Http\Models\Permission;
@@ -15,31 +14,27 @@ class PermissionController extends Controller
1514
private $userModel;
1615
private $permissionModel;
1716
private $configModel;
18-
private $container;
1917
private $rules;
2018
private $builderModel;
2119

2220
public function __construct(
2321
Request $request,
2422
Permission $permissionPepo,
2523
Config $configRepo,
26-
Container $container,
2724
PermissionRules $rules
28-
)
29-
{
25+
){
3026
$this->permissionModel = $permissionPepo;
3127
$this->configModel = $configRepo;
32-
$this->container = $container;
3328
$this->rules = $rules;
34-
$this->builderModel = $this->container->make('builderModel')->request($request);
29+
$this->builderModel = resolve('builderModel')->request($request);
3530
}
3631
public function index()
3732
{
3833
$pageSizes = $this->configModel->getPageSizes();
3934
$data = $this->builderModel->group('admin')
4035
->parent('name', 'parent', 'display_name')
4136
->getData($this->permissionModel);
42-
$table = $this->container->make('builderTable')
37+
$table = resolve('builderTable')
4338
->tabs($this->configModel->tabsGroupList('ENTRUST_GROUP_LIST'))
4439
->defaultTabs('admin')
4540
->data($data['model'])
@@ -55,10 +50,7 @@ public function index()
5550
->searchTitle('请输入搜索内容')
5651
->searchSelect(['id'=>'ID','name'=>'权限标识','email'=>'权限名称','mobile'=>'权限描述'])
5752
;
58-
return $this->container->make('builderHtml')
59-
->title('权限管理')
60-
->item($table)
61-
->response();
53+
return resolve('builderHtml')->title('权限管理')->item($table)->response();
6254
}
6355
public function delete(){
6456
if ($this->builderModel->delete($this->permissionModel)) {
@@ -67,16 +59,12 @@ public function delete(){
6759
'type' => 'success',
6860
];
6961
}
70-
return $this->container->make('builderHtml')->message($message)->response();
62+
return resolve('builderHtml')->message($message)->response();
7163
}
7264
public function add(Request $request){
7365
$form = $this->formItem(route('api.admin.user.permission.add'))
7466
->apiUrl('submit',route('api.admin.user.permission.store'));
75-
$html = $this->container->make('builderHtml')
76-
->title('新增权限')
77-
->item($form)
78-
->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])
79-
->response();
67+
$html = resolve('builderHtml')->title('新增权限')->item($form)->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])->response();
8068
return $request->group? $form->response(): $html;
8169

8270
}
@@ -88,7 +76,7 @@ public function store()
8876
'type' => 'success',
8977
];
9078
}
91-
return $this->container->make('builderHtml')->message($message)->response();
79+
return resolve('builderHtml')->message($message)->response();
9280
}
9381
public function edit(Request $request){
9482
$form = $this->formItem(route('api.admin.user.permission.edit'))
@@ -99,11 +87,7 @@ public function edit(Request $request){
9987
}else{
10088
$permission = $this->permissionModel->find($request->id);
10189
$form->itemData($permission->toArray());
102-
return $this->container->make('builderHtml')
103-
->title('编辑权限')
104-
->item($form)
105-
->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])
106-
->response();
90+
return resolve('builderHtml')->title('编辑权限')->item($form)->config('layout',['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])->response();
10791
}
10892
}
10993
public function update()
@@ -114,7 +98,7 @@ public function update()
11498
'type' => 'success',
11599
];
116100
}
117-
return $this->container->make('builderHtml')->message($message)->response();
101+
return resolve('builderHtml')->message($message)->response();
118102
}
119103
public function formItem($groupApiUrl){
120104
$groupList = $this->configModel->tabsGroupList('ENTRUST_GROUP_LIST');
@@ -124,7 +108,7 @@ public function formItem($groupApiUrl){
124108
'name',
125109
'display_name'
126110
);
127-
return $this->container->make('builderForm')
111+
return resolve('builderForm')
128112
->item(['name' => 'group', 'type' => 'select', 'label' => '权限分组',
129113
'placeholder' => '权限所属的分组','options'=>$groupList, 'value'=>'admin', 'apiUrl'=>$groupApiUrl])
130114
->item(['name' => 'parent', 'type' => 'select', 'label' => '上级权限',

0 commit comments

Comments
 (0)