2020-10-20 01:01:59 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-10-20 01:01:59 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-10-20 01:01:59 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2021-04-18 11:50:06 +02:00
|
|
|
use App\Models\Task;
|
2021-04-19 07:33:49 +02:00
|
|
|
use App\Models\TaskStatus;
|
2021-04-18 11:50:06 +02:00
|
|
|
|
2020-10-20 01:01:59 +02:00
|
|
|
/**
|
|
|
|
* Class for task status repository.
|
|
|
|
*/
|
|
|
|
class TaskStatusRepository extends BaseRepository
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
public function delete($task_status)
|
|
|
|
{
|
2021-04-19 11:59:11 +02:00
|
|
|
$ts = TaskStatus::where('company_id', $task_status->company_id)
|
2021-04-19 07:33:49 +02:00
|
|
|
->first();
|
|
|
|
|
2021-04-19 11:59:11 +02:00
|
|
|
$new_status = $ts ? $ts->id : null;
|
2021-04-18 11:50:06 +02:00
|
|
|
|
|
|
|
Task::where('status_id', $task_status->id)
|
|
|
|
->where('company_id', $task_status->company_id)
|
2021-04-19 07:33:49 +02:00
|
|
|
->update(['status_id' => $new_status]);
|
2021-04-18 11:50:06 +02:00
|
|
|
|
|
|
|
parent::delete($task_status);
|
|
|
|
|
|
|
|
return $task_status;
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2021-04-18 11:50:06 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
public function archive($task_status)
|
|
|
|
{
|
2021-04-19 07:33:49 +02:00
|
|
|
$task_status = TaskStatus::where('company_id', $task_status->company_id)
|
|
|
|
->first();
|
|
|
|
|
|
|
|
$new_status = $task_status ? $task_status->id : null;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-04-18 11:50:06 +02:00
|
|
|
Task::where('status_id', $task_status->id)
|
|
|
|
->where('company_id', $task_status->company_id)
|
2021-04-19 07:33:49 +02:00
|
|
|
->update(['status_id' => $new_status]);
|
2021-04-18 11:50:06 +02:00
|
|
|
|
|
|
|
parent::archive($task_status);
|
|
|
|
|
|
|
|
return $task_status;
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2020-10-20 01:01:59 +02:00
|
|
|
}
|