remove: soft delete

This commit is contained in:
tokumeikoi 2021-07-01 20:06:09 +09:00
parent 0f488540f4
commit b174403a2a
8 changed files with 15 additions and 28 deletions

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\Order;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class Test extends Command class Test extends Command
@ -37,5 +38,6 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
dd(Order::where('user_id', 4)->delete());
} }
} }

View File

@ -7,10 +7,10 @@ use App\Http\Requests\Admin\UserGenerate;
use App\Http\Requests\Admin\UserSendMail; use App\Http\Requests\Admin\UserSendMail;
use App\Http\Requests\Admin\UserUpdate; use App\Http\Requests\Admin\UserUpdate;
use App\Jobs\SendEmailJob; use App\Jobs\SendEmailJob;
use App\Services\UserService;
use App\Utils\Helper; use App\Utils\Helper;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\User; use App\Models\User;
use App\Models\Plan; use App\Models\Plan;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -277,16 +277,4 @@ class UserController extends Controller
'data' => true '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
]);
}
} }

View File

@ -25,12 +25,6 @@ class User
$request->session()->put('email', $user->email); $request->session()->put('email', $user->email);
$request->session()->put('id', $user->id); $request->session()->put('id', $user->id);
} }
// if ($request->input('lang')) {
// $request->session()->put('lang', $request->input('lang'));
// }
// if ($request->session()->get('lang')) {
// App::setLocale($request->session()->get('lang'));
// }
if (!$request->session()->get('id')) { if (!$request->session()->get('id')) {
abort(403, '未登录或登陆已过期'); abort(403, '未登录或登陆已过期');
} }

View File

@ -75,7 +75,6 @@ class AdminRoute
$router->post('/user/ban', 'Admin\\UserController@ban'); $router->post('/user/ban', 'Admin\\UserController@ban');
$router->post('/user/resetSecret', 'Admin\\UserController@resetSecret'); $router->post('/user/resetSecret', 'Admin\\UserController@resetSecret');
$router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser'); $router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser');
$router->post('/user/drop', 'Admin\\UserController@drop');
// StatOrder // StatOrder
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride'); $router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
$router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank'); $router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');

View File

@ -3,11 +3,9 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model class User extends Model
{ {
use SoftDeletes;
protected $table = 'v2_user'; protected $table = 'v2_user';
protected $dateFormat = 'U'; protected $dateFormat = 'U';
protected $guarded = ['id']; protected $guarded = ['id'];

View File

@ -2,9 +2,12 @@
namespace App\Services; namespace App\Services;
use App\Models\InviteCode;
use App\Models\Order; use App\Models\Order;
use App\Models\Server; use App\Models\Server;
use App\Models\Ticket;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\DB;
class UserService class UserService
{ {

View File

@ -342,10 +342,9 @@ CREATE TABLE `v2_user` (
`expired_at` bigint(20) DEFAULT '0', `expired_at` bigint(20) DEFAULT '0',
`created_at` int(11) NOT NULL, `created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL,
`deleted_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `email_deleted_at` (`email`,`deleted_at`) UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2021-06-30 15:34:40 -- 2021-07-01 11:00:48

View File

@ -412,9 +412,13 @@ ALTER TABLE `v2_order`
ALTER TABLE `v2_payment` ALTER TABLE `v2_payment`
ADD `uuid` char(32) NOT NULL AFTER `id`; ADD `uuid` char(32) NOT NULL AFTER `id`;
ALTER TABLE `v2_user`
ADD `deleted_at` int(11) NULL AFTER `updated_at`;
ALTER TABLE `v2_user` ALTER TABLE `v2_user`
ADD UNIQUE `email_deleted_at` (`email`, `deleted_at`), ADD UNIQUE `email_deleted_at` (`email`, `deleted_at`),
DROP INDEX `email`; DROP INDEX `email`;
ALTER TABLE `v2_user`
DROP `deleted_at`;
ALTER TABLE `v2_user`
ADD UNIQUE `email` (`email`),
DROP INDEX `email_deleted_at`;