Skip to content

Commit

Permalink
can create same name task as was deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Sep 5, 2024
1 parent f187641 commit 47f567a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Requests/TaskRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function rules(): array
'required',
'string',
'max:255',
Rule::unique('tasks')->ignore($this->route()?->parameter('task')),
Rule::unique('tasks')->withoutTrashed()->ignore($this->route()?->parameter('task')),
]
];
}
Expand Down
13 changes: 13 additions & 0 deletions app/Services/TaskNotification/NotificationFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Services\TaskNotification;

use App\Models\TaskNotification;

class NotificationFactory
{
public function create()
{
return new TaskNotification();
}
}
6 changes: 4 additions & 2 deletions app/Services/TaskNotification/TaskNotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class TaskNotificationService
{
protected Task $task;
protected ?TaskComment $comment;
protected NotificationFactory $factory;

public function __construct()
public function __construct(NotificationFactory $notFactory)
{
$this->task = request('task', null);
$this->comment = request('comment', null);
$this->factory = $notFactory;
}

public function retrieveWithDelete()
Expand Down Expand Up @@ -56,7 +58,7 @@ public function storeSeveral(string $labelName, array $recipientsIds = [], ?Task
return $carry;
}

$notification = new TaskNotification();
$notification = $this->factory->create();
$notification->comment()->associate($comment);
$notification->recipient()->associate($userId);
$notification->label()->associate($label);
Expand Down

0 comments on commit 47f567a

Please sign in to comment.