切换员工身份
parent
50fb013f22
commit
cfcc3b1b3c
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Grid;
|
||||
|
||||
use App\Models\User;
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserCompany extends RowAction
|
||||
{
|
||||
public function title()
|
||||
{
|
||||
return '<i class="feather icon-users grid-action-icon"></i> 切换员工 ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the action request.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$user = User::findOrFail($this->getKey());
|
||||
|
||||
$user->userInfo->update([
|
||||
'is_company' => $user->userInfo->is_company ? 0 : 1
|
||||
]);
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|array|void
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
return ['是否确定?'];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Grid\DisableUser;
|
||||
use App\Admin\Actions\Grid\EnableUser;
|
||||
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;
|
||||
|
|
@ -80,8 +80,8 @@ class UserController extends AdminController
|
|||
// PriceBetween::make()
|
||||
// );
|
||||
|
||||
$grid->column('userInfo.is_company')->bool();
|
||||
$grid->column('created_at')->sortable();
|
||||
$grid->column('register_ip');
|
||||
$grid->column('status')->using([-1=>'冻结', 1=>'正常', 2=>'禁用'])
|
||||
->dot([
|
||||
-1 => '#b3b9bf',
|
||||
|
|
@ -110,21 +110,22 @@ class UserController extends AdminController
|
|||
$actions->append(new EnableUser());
|
||||
}
|
||||
}
|
||||
$actions->append(new UserCompany());
|
||||
|
||||
// 冻结资产
|
||||
if (Admin::user()->can('dcat.admin.users.frozen')) {
|
||||
$actions->append(new Frozen());
|
||||
}
|
||||
// if (Admin::user()->can('dcat.admin.users.frozen')) {
|
||||
// $actions->append(new Frozen());
|
||||
// }
|
||||
|
||||
// 重置用户密码
|
||||
if (Admin::user()->can('dcat.admin.users.reset_password')) {
|
||||
$actions->append(new UserResetPassword());
|
||||
}
|
||||
// if (Admin::user()->can('dcat.admin.users.reset_password')) {
|
||||
// $actions->append(new UserResetPassword());
|
||||
// }
|
||||
|
||||
// 重置用户账户密码
|
||||
if (Admin::user()->can('dcat.admin.users.reset_account_password')) {
|
||||
$actions->append(new UserResetAccountPassword());
|
||||
}
|
||||
// if (Admin::user()->can('dcat.admin.users.reset_account_password')) {
|
||||
// $actions->append(new UserResetAccountPassword());
|
||||
// }
|
||||
});
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,6 @@ class UserController extends Controller
|
|||
'id' => $user->id,
|
||||
'phone' => $user->phone,
|
||||
'user_info' => UserInfoResource::make($user->userInfo),
|
||||
'is_vip' => $user->isVip(),
|
||||
'wallet' => UserWalletResource::make($user->wallet),
|
||||
'balance' => UserBalanceResource::make($user->balance),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class MiniprogramController extends Controller
|
|||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'token' => $token->plainTextToken,
|
||||
'token' => $token->plainTextToken
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
DB::rollBack();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class StoreResource extends JsonResource
|
|||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $this->id,
|
||||
'title' => (string) $this->title,
|
||||
'image' => (string) $this->image,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ class UserInfoResource extends JsonResource
|
|||
'gender' => (string) $this->gender,
|
||||
'birthday' => (string) $this->birthday?->toDateString(),
|
||||
'code' => (string) $this->code,
|
||||
'growth_value' => $this->growth_value, //用户成长值
|
||||
'points' => (int) $this->points,
|
||||
'is_company' => (boolean) $this->is_company
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class UserInfo extends Model
|
|||
'path',
|
||||
'growth_value',
|
||||
'real_inviter_id',
|
||||
'is_company'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ return [
|
|||
'phone' =>'推荐人手机',
|
||||
],
|
||||
],
|
||||
'is_company' => '员工',
|
||||
],
|
||||
'user_info'=>[
|
||||
'avatar' => '头像',
|
||||
|
|
|
|||
Loading…
Reference in New Issue