admin/user show UserCompany
parent
558eedbd3d
commit
76a3c7e676
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Show;
|
||||
|
||||
use App\Admin\Forms\UserCompany as UserCompanyForm;
|
||||
use Dcat\Admin\Show\AbstractTool;
|
||||
use Dcat\Admin\Widgets\Modal;
|
||||
|
||||
class UserCompany extends AbstractTool
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$form = UserCompanyForm::make()->payload(['id'=>$this->getKey()]);
|
||||
return Modal::make()
|
||||
->lg()
|
||||
->title('员工')
|
||||
->body($form)
|
||||
->button("<a href=\"javascript:void(0)\" class=\"btn btn-sm btn-warning\">设为员工</a> ");
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ use App\Admin\Actions\Grid\{EnableUser, UserCompany};
|
|||
use App\Admin\Actions\Grid\Frozen;
|
||||
use App\Admin\Actions\Grid\UserResetAccountPassword;
|
||||
use App\Admin\Actions\Grid\UserResetPassword;
|
||||
use App\Admin\Actions\Show\UserEditBank;
|
||||
use App\Admin\Actions\Show\{UserEditBank, UserCompany as UserCompanyShow};
|
||||
use App\Admin\Actions\Show\UserEditPhone;
|
||||
use App\Admin\Actions\Show\UserEditAgent;
|
||||
use App\Admin\Renderable\Grid\Filter\PriceBetween;
|
||||
|
|
@ -165,7 +165,7 @@ class UserController extends AdminController
|
|||
|
||||
$show->field('user_info.growth_value');
|
||||
$show->field('profit');
|
||||
$show->field('userInfo.is_company')->as(function ($v) {
|
||||
$show->field('user_info.is_company')->as(function ($v) {
|
||||
return $v ? '是' : '否';
|
||||
});
|
||||
|
||||
|
|
@ -180,9 +180,9 @@ class UserController extends AdminController
|
|||
// $show->field('user_info.points');
|
||||
});
|
||||
$show->row(function (Show\Row $show) {
|
||||
// $show->width(6)->field('last_login_ip');
|
||||
$show->width(6)->field('last_login_ip');
|
||||
$show->width(6)->field('last_login_at');
|
||||
// $show->field('register_ip');
|
||||
$show->field('register_ip');
|
||||
$show->field('created_at');
|
||||
});
|
||||
|
||||
|
|
@ -202,6 +202,7 @@ class UserController extends AdminController
|
|||
if (Admin::user()->can('dcat.admin.users.agent')) {
|
||||
$tools->append(new UserEditAgent());
|
||||
}
|
||||
$tools->append(new UserCompanyShow());
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\{User, Agent};
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
use Dcat\Admin\Contracts\LazyRenderable;
|
||||
use Dcat\Admin\Traits\LazyWidget;
|
||||
|
||||
class UserCompany extends Form implements LazyRenderable
|
||||
{
|
||||
use LazyWidget;
|
||||
public function handle(array $input)
|
||||
{
|
||||
$id = $this->payload['id'] ?? 0;
|
||||
$user = User::findOrFail($id);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$user->userInfo->update([
|
||||
'is_company' => $input['is_company']
|
||||
]);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return $this->response()->error('操作失败:'.$th->getMessage());
|
||||
}
|
||||
|
||||
return $this->response()->success(__('admin.update_succeeded'))->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$id = $this->payload['id'] ?? 0;
|
||||
$user = User::with(['userInfo'])->findOrFail($id);
|
||||
|
||||
$this->radio('is_company', '员工')->value($user->userInfo->is_company)->options([1 => '是', 0 => '否']);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
return [
|
||||
'labels' => [
|
||||
'User' => '会员管理',
|
||||
'users' => '会员管理',
|
||||
'User' => '用户管理',
|
||||
'users' => '用户管理',
|
||||
],
|
||||
'fields' => [
|
||||
'username' => '用户名',
|
||||
|
|
@ -12,23 +12,11 @@ return [
|
|||
'phone' => '手机号',
|
||||
'email' => '邮箱',
|
||||
'status'=>'状态',
|
||||
'last_login_ip' => '最近登录IP',
|
||||
'last_login_at' => '最近登录时间',
|
||||
'last_login_ip' => '最近IP',
|
||||
'last_login_at' => '最近时间',
|
||||
'register_ip' => '注册IP',
|
||||
'created_at' => '注册时间',
|
||||
'agent' => '代理',
|
||||
'userInfo'=>[
|
||||
'avatar' => '头像',
|
||||
'nickname' => '昵称',
|
||||
'code' => '邀请码',
|
||||
'growth_value'=>'成长值',
|
||||
'inviterInfo'=>[
|
||||
'user'=>[
|
||||
'phone' =>'推荐人手机',
|
||||
],
|
||||
],
|
||||
'is_company' => '员工',
|
||||
],
|
||||
'user_info'=>[
|
||||
'avatar' => '头像',
|
||||
'nickname' => '昵称',
|
||||
|
|
@ -38,9 +26,10 @@ return [
|
|||
'birthday'=>'生日',
|
||||
'inviter_info'=>[
|
||||
'user'=>[
|
||||
'phone' =>'推荐人手机',
|
||||
'phone' =>'推荐人',
|
||||
],
|
||||
],
|
||||
'is_company' => '员工',
|
||||
],
|
||||
'wallet'=>[
|
||||
'balance'=>'可提',
|
||||
|
|
|
|||
Loading…
Reference in New Issue