-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1489 from bakaphp/refact-tags
refact: add relationship
- Loading branch information
Showing
5 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/GraphQL/ActionEngine/Mutations/Engagements/TaskEngagementMutation.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\GraphQL\ActionEngine\Mutations\Engagements; | ||
|
||
use Kanvas\ActionEngine\Tasks\Models\TaskListItem; | ||
use Kanvas\Apps\Models\Apps; | ||
use Kanvas\Exceptions\ValidationException; | ||
|
||
class TaskEngagementMutation | ||
{ | ||
public function changeEngagementTaskItemStatus(mixed $rootValue, array $request): bool | ||
{ | ||
$id = (int) $request['id']; | ||
$user = auth()->user(); | ||
$company = $user->getCurrentCompany(); | ||
$app = app(Apps::class); | ||
$status = $request['status']; | ||
|
||
$taskListItem = TaskListItem::getById($id); | ||
|
||
if ($taskListItem->companyAction->company_id != $company->getId()) { | ||
throw new ValidationException('You are not allowed to change the status of this task'); | ||
} | ||
|
||
if ($taskListItem->companyAction->apps_id != $app->getId()) { | ||
throw new ValidationException('You are not allowed to change the status of this task'); | ||
} | ||
|
||
$taskListItem->status = $status; | ||
|
||
return $taskListItem->saveOrFail(); | ||
} | ||
} |
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
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
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
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