|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
|
|
use App\Admin\Repositories\DistAdminUser;
|
|
|
+use App\Models\DistProductCategory;
|
|
|
use Dcat\Admin\Form;
|
|
|
use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
@@ -144,11 +145,21 @@ class DistAdminUserController extends AdminController
|
|
|
//保存后回调
|
|
|
$form->saved(function (Form $form, $result) {
|
|
|
if ($form->isCreating()) {
|
|
|
+ //添加角色
|
|
|
$newId = $form->getKey();
|
|
|
if (! $newId) {
|
|
|
return $form->response()->error('Failed to save data');
|
|
|
}
|
|
|
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_user_id'=>$newId,
|
|
|
+ ]);
|
|
|
}
|
|
|
});
|
|
|
});
|