Skip to content

Commit 2ea042e

Browse files
committed
wip
1 parent 4e55b22 commit 2ea042e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/Actions/Action.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,30 @@ public function payload(): array
8888
return [];
8989
}
9090

91-
abstract public function handle(ActionRequest $request, Collection $models): JsonResponse;
91+
// abstract public function handle(ActionRequest $request, Collection $models): JsonResponse;
9292

9393
public function handleRequest(ActionRequest $request)
9494
{
95-
if (! method_exists($this, 'handle')) {
95+
if (!method_exists($this, 'handle')) {
9696
throw new Exception('Missing handle method from the action.');
9797
}
9898

9999
$response = null;
100100

101-
$request->collectRepositories($this, static::$chunkCount, function ($models) use ($request, &$response) {
102-
Transaction::run(function () use ($models, $request, &$response) {
103-
$response = $this->handle($request, $models);
101+
if (!$request->isForRepositoryRequest()) {
102+
$request->collectRepositories($this, static::$chunkCount, function ($models) use ($request, &$response) {
103+
Transaction::run(function () use ($models, $request, &$response) {
104+
$response = $this->handle($request, $models);
105+
});
104106
});
105-
});
107+
} else {
108+
Transaction::run(function () use ($request, &$response) {
109+
$response = $this->handle(
110+
$request,
111+
$request->findModelOrFail()
112+
);
113+
});
114+
}
106115

107116
return $response;
108117
}

0 commit comments

Comments
 (0)