FupingQiu / okrsw

0 stars 0 forks source link

Laravel Job:Type error: Too few arguments to function App\Jobs\AnalyseActivitiesQuality::__construct() #9

Closed FupingQiu closed 6 years ago

FupingQiu commented 6 years ago

Type error: Too few arguments to function App\Jobs\AnalyseActivitiesQuality::__construct()

[2018-09-14 16:38:14] local.ERROR: Type error: Too few arguments to function App\Jobs\AnalyseActivitiesQuality::construct(), 0 passed in D:\laragon\www\OKRsWalking\app\Console\Kernel.php on line 30 and exactly 3 expected {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Too few arguments to function App\Jobs\AnalyseActivitiesQuality::construct(), 0 passed in D:\laragon\www\OKRsWalking\app\Console\Kernel.php on line 30 and exactly 3 expected at D:\laragon\www\OKRsWalking\app\Jobs\AnalyseActivitiesQuality.php:43) [stacktrace]

FupingQiu commented 6 years ago

__construct() 用途: 创建实例,用于参数的传输 可以为空,不需要传参数的时候。

handle() 用途: 用于执行任务,逻辑处理;包括初始化实例 需要创建实例,用于调用实例,进行类的调用,如handle(User $user),此时可以进行$user->first()等操作。laravel 5.6 document 中:handle 方法在任务被处理的时候调用,注意我们可以在任务的 handle 方法中进行依赖注入。Laravel 服务容器会自动注入这些依赖。