|
@@ -2,14 +2,13 @@
|
|
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
|
|
+use App\Admin\Renderable\DistDistributorTable;
|
|
|
use App\Admin\Repositories\DistAdminUser;
|
|
|
-use App\Models\DistProductCategory;
|
|
|
use Dcat\Admin\Form;
|
|
|
use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
use Dcat\Admin\Layout\Content;
|
|
|
-use Dcat\Admin\Admin;
|
|
|
|
|
|
class DistAdminUserController extends AdminController
|
|
|
{
|
|
@@ -19,8 +18,8 @@ class DistAdminUserController extends AdminController
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
return $content
|
|
|
- ->header('Distribution Management')
|
|
|
- ->description('Distribution Management')
|
|
|
+ ->header('Users Management')
|
|
|
+ ->description('Users Management')
|
|
|
->breadcrumb(['text'=>'list','url'=>''])
|
|
|
->body($this->grid());
|
|
|
}
|
|
@@ -32,20 +31,23 @@ class DistAdminUserController extends AdminController
|
|
|
*/
|
|
|
protected function grid()
|
|
|
{
|
|
|
- return Grid::make(new DistAdminUser(), function (Grid $grid) {
|
|
|
+ return Grid::make(DistAdminUser::with(['distributor']), function (Grid $grid) {
|
|
|
//指定表格视图,去掉右上角的操作按钮
|
|
|
$grid->view('admin.grid.table');
|
|
|
//设置列表
|
|
|
$grid->column('id')->sortable();
|
|
|
$grid->column('username');
|
|
|
- $grid->column('name','Company Name');
|
|
|
+ $grid->column('name');
|
|
|
+ $grid->column('distributor.company_name','Company Name');
|
|
|
+ $grid->column('distributor.level_domain','Level Domain');
|
|
|
$grid->column('language')->using(config('dictionary.languages'));
|
|
|
$grid->column('enabled')->switch();
|
|
|
$grid->column('created_at');
|
|
|
$grid->column('updated_at')->sortable();
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
|
$filter->equal('username');
|
|
|
- $filter->equal('name','company name');
|
|
|
+ $filter->equal('name','name');
|
|
|
+ $filter->like('distributor.company_name', 'Company Name');
|
|
|
});
|
|
|
//排序
|
|
|
$grid->model()->orderBy("id",'desc');
|
|
@@ -67,28 +69,29 @@ class DistAdminUserController extends AdminController
|
|
|
*/
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
- return Show::make($id, DistAdminUser::with(['info']), function (Show $show) {
|
|
|
+ return Show::make($id, DistAdminUser::with(['distributor']), function (Show $show) {
|
|
|
$show->row(function (Show\Row $show) {
|
|
|
$show->width(6)->field('id');
|
|
|
$show->width(6)->field('username');
|
|
|
+ $show->width(6)->field('name','name');
|
|
|
$show->width(6)->field('info.site_name','Site Name');
|
|
|
- $show->width(6)->field('name','Company Name');
|
|
|
- $show->width(6)->field('info.country','Country');
|
|
|
- $show->width(6)->field('info.contact_number','Contact Number');
|
|
|
- $show->width(6)->field('info.service_hotline','Service Hotline');
|
|
|
- $show->width(6)->field('info.whats_app','whatsApp');
|
|
|
- $show->width(6)->field('info.facebook','Facebook');
|
|
|
- $show->width(6)->field('info.instagram','Instagram');
|
|
|
- $show->width(6)->field('info.youtube','Youtube');
|
|
|
- $show->width(6)->field('info.linkedin','Linkedin');
|
|
|
- $show->width(6)->field('info.tiktok','Tiktok');
|
|
|
- $show->width(6)->field('info.second_level_domain','Second Level Domain');
|
|
|
+ $show->width(6)->field('distributor.level_domain','Level Domain');
|
|
|
+ $show->width(6)->field('distributor.company_name', 'Company Name');
|
|
|
+ $show->width(6)->field('distributor.country','Country');
|
|
|
+ $show->width(6)->field('distributor.contact_number','Contact Number');
|
|
|
+ $show->width(6)->field('distributor.service_hotline','Service Hotline');
|
|
|
+ $show->width(6)->field('distributor.whats_app','whatsApp');
|
|
|
+ $show->width(6)->field('distributor.facebook','Facebook');
|
|
|
+ $show->width(6)->field('distributor.instagram','Instagram');
|
|
|
+ $show->width(6)->field('distributor.youtube','Youtube');
|
|
|
+ $show->width(6)->field('distributor.linkedin','Linkedin');
|
|
|
+ $show->width(6)->field('distributor.tiktok','Tiktok');
|
|
|
$show->width(6)->field('language')->using(config('dictionary.languages'));
|
|
|
$show->width(6)->field('enabled')->using(config('dictionary.enabled'));
|
|
|
+ $show->width(6)->field('distributor.company_address','Company Address');
|
|
|
$show->width(6)->field('created_at');
|
|
|
$show->width(6)->field('updated_at');
|
|
|
- $show->width(6)->field('info.company_address','Company Address');
|
|
|
- $show->width(6)->field('info.remark','Remark');
|
|
|
+ $show->width(6)->field('distributor.remark','Remark');
|
|
|
});
|
|
|
});
|
|
|
}
|
|
@@ -100,31 +103,18 @@ class DistAdminUserController extends AdminController
|
|
|
*/
|
|
|
protected function form()
|
|
|
{
|
|
|
- return Form::make(DistAdminUser::with(['info']), function (Form $form) {
|
|
|
+ return Form::make(DistAdminUser::with(['distributor']), function (Form $form) {
|
|
|
$form->display('id');
|
|
|
$form->text('username')->required();
|
|
|
$form->password('password')->customFormat(function ($v) {
|
|
|
return "";
|
|
|
});
|
|
|
- $form->text('name','Company Name')->required();
|
|
|
- $form->text('info.site_name','Site Name')->required();
|
|
|
- $form->text('info.second_level_domain','Second Level Domain')->required();
|
|
|
+ $form->text('name','name')->required();
|
|
|
$form->select('language')->options(config('dictionary.languages'))->required();
|
|
|
$form->switch('enabled')->default(1);
|
|
|
-
|
|
|
- $form->fieldset('Contact Information', function (Form $form) {
|
|
|
- $form->text('info.country','Country');
|
|
|
- $form->text('info.contact_number','Contact Number');
|
|
|
- $form->text('info.service_hotline','Service Hotline');
|
|
|
- $form->text('info.whats_app','WhatsApp');
|
|
|
- $form->text('info.facebook','Facebook');
|
|
|
- $form->text('info.instagram','Instagram');
|
|
|
- $form->text('info.youtube','Youtube');
|
|
|
- $form->text('info.linkedin','Linkedin');
|
|
|
- $form->text('info.tiktok','Tiktok');
|
|
|
- $form->textarea('info.company_address','Company Address');
|
|
|
- $form->textarea('info.remark','Remark');
|
|
|
- });
|
|
|
+ $form->selectTable('dist_id', 'Select Distributor')
|
|
|
+ ->title('distId')
|
|
|
+ ->from(DistDistributorTable::make());
|
|
|
//保存前回调
|
|
|
$form->saving(function (Form $form) {
|
|
|
//判断用户名是否重复
|
|
@@ -152,14 +142,14 @@ class DistAdminUserController extends AdminController
|
|
|
}
|
|
|
DistAdminUser::addRoleUser($newId, config('dictionary.dist_role_id'));//分销商角色ID 2
|
|
|
//分配默认分类
|
|
|
- $distProductCategory = new DistProductCategory();
|
|
|
- $distProductCategory->create([
|
|
|
- 'parent_id' => 0,
|
|
|
- 'name' => 'Default Category',
|
|
|
- 'order' => 0,
|
|
|
- 'enabled' => 1,
|
|
|
- 'dist_id'=>$newId,
|
|
|
- ]);
|
|
|
+// $distProductCategory = new DistProductCategory();
|
|
|
+// $distProductCategory->create([
|
|
|
+// 'parent_id' => 0,
|
|
|
+// 'name' => 'Default Category',
|
|
|
+// 'order' => 0,
|
|
|
+// 'enabled' => 1,
|
|
|
+// 'dist_id'=>$newId,
|
|
|
+// ]);
|
|
|
}
|
|
|
});
|
|
|
});
|