mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add user softdelete api
This commit is contained in:
parent
044d1e9b7f
commit
de6ff1dca9
@ -277,4 +277,16 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop(Request $request)
|
||||
{
|
||||
$user = User::find($request->input('id'));
|
||||
if (!$user) abort(500, '用户不存在');
|
||||
if (!$user->delete()) {
|
||||
abort(500, '删除失败');
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ class AdminRoute
|
||||
$router->post('/user/ban', 'Admin\\UserController@ban');
|
||||
$router->post('/user/resetSecret', 'Admin\\UserController@resetSecret');
|
||||
$router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser');
|
||||
$router->post('/user/drop', 'Admin\\UserController@drop');
|
||||
// StatOrder
|
||||
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
||||
$router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');
|
||||
|
@ -3,9 +3,11 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'v2_user';
|
||||
protected $dateFormat = 'U';
|
||||
protected $guarded = ['id'];
|
||||
|
@ -342,9 +342,10 @@ CREATE TABLE `v2_user` (
|
||||
`expired_at` bigint(20) DEFAULT '0',
|
||||
`created_at` int(11) NOT NULL,
|
||||
`updated_at` int(11) NOT NULL,
|
||||
`deleted_at` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `email` (`email`)
|
||||
UNIQUE KEY `email_deleted_at` (`email`,`deleted_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
-- 2021-05-06 16:14:04
|
||||
-- 2021-06-30 15:34:40
|
||||
|
@ -411,3 +411,10 @@ ALTER TABLE `v2_order`
|
||||
|
||||
ALTER TABLE `v2_payment`
|
||||
ADD `uuid` char(32) NOT NULL AFTER `id`;
|
||||
|
||||
ALTER TABLE `v2_user`
|
||||
ADD `deleted_at` int(11) NOT NULL AFTER `updated_at`;
|
||||
|
||||
ALTER TABLE `v2_user`
|
||||
ADD UNIQUE `email_deleted_at` (`email`, `deleted_at`),
|
||||
DROP INDEX `email`;
|
||||
|
Loading…
Reference in New Issue
Block a user