mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
set a default task_status for orphaned tasks
This commit is contained in:
parent
25fe52ab18
commit
060404cd6c
@ -12,6 +12,7 @@
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Task;
|
||||
use App\Models\TaskStatus;
|
||||
|
||||
/**
|
||||
* Class for task status repository.
|
||||
@ -21,10 +22,14 @@ class TaskStatusRepository extends BaseRepository
|
||||
|
||||
public function delete($task_status)
|
||||
{
|
||||
$task_status = TaskStatus::where('company_id', $task_status->company_id)
|
||||
->first();
|
||||
|
||||
$new_status = $task_status ? $task_status->id : null;
|
||||
|
||||
Task::where('status_id', $task_status->id)
|
||||
->where('company_id', $task_status->company_id)
|
||||
->update(['status_id' => null]);
|
||||
->update(['status_id' => $new_status]);
|
||||
|
||||
|
||||
parent::delete($task_status);
|
||||
@ -36,9 +41,14 @@ class TaskStatusRepository extends BaseRepository
|
||||
public function archive($task_status)
|
||||
{
|
||||
|
||||
$task_status = TaskStatus::where('company_id', $task_status->company_id)
|
||||
->first();
|
||||
|
||||
$new_status = $task_status ? $task_status->id : null;
|
||||
|
||||
Task::where('status_id', $task_status->id)
|
||||
->where('company_id', $task_status->company_id)
|
||||
->update(['status_id' => null]);
|
||||
->update(['status_id' => $new_status]);
|
||||
|
||||
|
||||
parent::archive($task_status);
|
||||
|
Loading…
Reference in New Issue
Block a user