1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Laravel Love. |
5
|
|
|
* |
6
|
|
|
* (c) Anton Komarev <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Cog\Laravel\Love\Reactant\Jobs; |
15
|
|
|
|
16
|
|
|
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantContract; |
17
|
|
|
use Cog\Contracts\Love\Reaction\Models\Reaction as ReactionContract; |
18
|
|
|
use Cog\Laravel\Love\Reactant\ReactionCounter\Services\ReactionCounterService; |
19
|
|
|
use Cog\Laravel\Love\Reactant\ReactionTotal\Services\ReactionTotalService; |
20
|
|
|
use Illuminate\Bus\Queueable; |
21
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
22
|
|
|
use Illuminate\Foundation\Bus\Dispatchable; |
23
|
|
|
|
24
|
|
|
final class IncrementAggregatesJob implements |
25
|
|
|
ShouldQueue |
26
|
|
|
{ |
27
|
|
|
use Dispatchable; |
28
|
|
|
use Queueable; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \Cog\Contracts\Love\Reactant\Models\Reactant |
32
|
|
|
*/ |
33
|
|
|
private $reactant; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \Cog\Contracts\Love\Reaction\Models\Reaction |
37
|
|
|
*/ |
38
|
|
|
private $reaction; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param \Cog\Contracts\Love\Reactant\Models\Reactant $reactant |
42
|
|
|
* @param \Cog\Contracts\Love\Reaction\Models\Reaction $reaction |
43
|
|
|
*/ |
44
|
|
|
public function __construct( |
45
|
|
|
ReactantContract $reactant, |
46
|
|
|
ReactionContract $reaction |
47
|
|
|
) { |
48
|
|
|
$this->reactant = $reactant; |
49
|
|
|
$this->reaction = $reaction; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function handle(): void |
53
|
|
|
{ |
54
|
|
|
(new ReactionCounterService($this->reactant)) |
55
|
|
|
->addReaction($this->reaction); |
56
|
|
|
|
57
|
|
|
(new ReactionTotalService($this->reactant)) |
58
|
|
|
->addReaction($this->reaction); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|