Created
December 19, 2020 04:16
-
-
Save 77web/2b5399d2c5b9fac21b11ecf9b9022c74 to your computer and use it in GitHub Desktop.
Laravelのキュー周りこういう書き方したらだめですかね?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namepace App\Jobs; | |
// 略 | |
class FooJob implements ShouldQueue | |
{ | |
private $param1; | |
private $param2; | |
public function __construct($param1, $param2) | |
{ | |
$this->param1 = $param1; | |
$this->param2 = $param2; | |
} | |
public function handle(FooHandler $fooHandler) | |
{ | |
$fooHandler->handle($this); | |
} | |
// 略 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Jobs\Handler; | |
// 略 | |
class FooJobHandler | |
{ | |
private $fooService; | |
public function __construct(FooService $fooService) | |
{ | |
$this->fooService = $fooService; | |
} | |
public function handle(FooJob $job): void | |
{ | |
// some more logic here | |
$this->fooService->foo($job->getParam1(), $job->getParam2()); | |
// some more logic here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment