动态调用

This commit is contained in:
iVampireSP.com 2023-02-13 03:06:27 +08:00
parent cf638fddb4
commit 3d2b32eda0
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
5 changed files with 5 additions and 5 deletions

View File

@ -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')),

View File

@ -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')),

View File

@ -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'));
}

View File

@ -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) {

View File

@ -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) {