diff --git a/app/Http/Controllers/Application/UserController.php b/app/Http/Controllers/Application/UserController.php index 3249637..ec3f550 100644 --- a/app/Http/Controllers/Application/UserController.php +++ b/app/Http/Controllers/Application/UserController.php @@ -25,7 +25,7 @@ public function store(Request $request): JsonResponse 'password' => 'required|string|min:6', ]); - $user = User::create([ + $user = (new User)->create([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), diff --git a/app/Http/Controllers/Module/UserController.php b/app/Http/Controllers/Module/UserController.php index 011abf6..6cb9394 100644 --- a/app/Http/Controllers/Module/UserController.php +++ b/app/Http/Controllers/Module/UserController.php @@ -48,7 +48,7 @@ public function store(Request $request): JsonResponse 'password' => 'required|string|min:6', ]); - $user = User::create([ + $user = (new User)->create([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), diff --git a/app/Http/Controllers/Web/HostController.php b/app/Http/Controllers/Web/HostController.php index 8479209..73d91cf 100644 --- a/app/Http/Controllers/Web/HostController.php +++ b/app/Http/Controllers/Web/HostController.php @@ -16,7 +16,7 @@ class HostController extends Controller */ public function index(): View { - $hosts = Host::thisUser()->with(['user', 'module'])->paginate(20); + $hosts = (new Host)->thisUser()->with(['user', 'module'])->paginate(20); return view('hosts.index', compact('hosts')); } diff --git a/app/Jobs/Host/SendRenewNotificationJob.php b/app/Jobs/Host/SendRenewNotificationJob.php index e5c5cff..b770b09 100644 --- a/app/Jobs/Host/SendRenewNotificationJob.php +++ b/app/Jobs/Host/SendRenewNotificationJob.php @@ -35,7 +35,7 @@ public function handle(): void { if (! $this->host) { // 获取 Host,距离今天刚好 7 天的 Host - Host::where('next_due_at', '>', now()->addDays(7)->startOfDay()) + (new Host)->where('next_due_at', '>', now()->addDays(7)->startOfDay()) ->where('next_due_at', '<', now()->addDays(7)->endOfDay()) ->chunk(100, function ($hosts) { foreach ($hosts as $host) { diff --git a/app/Jobs/Host/SuspendOverdueHosts.php b/app/Jobs/Host/SuspendOverdueHosts.php index df1a429..8488567 100644 --- a/app/Jobs/Host/SuspendOverdueHosts.php +++ b/app/Jobs/Host/SuspendOverdueHosts.php @@ -33,7 +33,7 @@ public function __construct(?Host $host = null) public function handle(): void { if (!$this->host) { - Host::where('next_due_at', '<', now()) + (new Host)->where('next_due_at', '<', now()) ->where('status', '!=', 'suspended') ->chunk(100, function ($hosts) { foreach ($hosts as $host) {