8000 Add helper method to client dispatchable trait · CodingSeo/laravel-json-api@c7fc5ff · GitHub
[go: up one dir, main page]

Skip to content

Commit c7fc5ff

Browse files
committed
Add helper method to client dispatchable trait
1 parent 51df5f3 commit c7fc5ff

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Queue/ClientDispatchable.php

Lines changed: 17 additions & 0 deletions
< 80A2 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,21 @@ public function resourceId(): ?string
6363
{
6464
return optional($this->clientJob)->resource_id;
6565
}
66+
67+
/**
68+
* Set the resource that the job relates to.
69+
*
70+
* If a job is creating a new resource, this method can be used to update
71+
* the client job with the created resource. This method does nothing if the
72+
* job was not dispatched by a client.
73+
*
74+
* @param $resource
75+
* @return void
76+
*/
77+
public function setResource($resource): void
78+
{
79+
if ($this->wasClientDispatched()) {
80+
$this->clientJob->setResource($resource)->save();
81+
}
82+
}
6683
}

0 commit comments

Comments
 (0)
0