This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

52
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Nwidart\Modules\Facades\Module as ModuleManager;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$this->modules($schedule);
}
/**
* 要执行任务的位置增加Console\Kernel类
* 类中 runCommand(Schedule $schedule)
* 模型中的command在模型的ServiceProvider自行注册
*
* @param Schedule $schedule
*/
protected function modules(Schedule $schedule)
{
$data = ModuleManager::toCollection();
foreach ($data as $name => $module) {
$class = "\\Modules\\$name\\Console\\Kernel";
if (class_exists($class)) {
$runKernel = resolve($class);
$runKernel->runCommand($schedule);
}
}
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
// $this->load(__DIR__.'/Commands');
}
}