Add images to tasks
Everyone who may comment on a task sends images to it, e.g. photos taken with a phone. The server stores an upright, at most 2560 px JPEG without EXIF data (no location) and a 400 px thumbnail on the private disk, served only to those who see the job. Uploaders change captions (also the alt text) and remove their own images; admin and management may remove anyone's (jobs.remove-any-task-image). Removing a task also removes its image files. Livewire's temporary upload limit is raised to PHP's 40 MB so that the page's own 12 MB limit gives a translated message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\UseCases;
|
||||
|
||||
use App\Modules\Jobs\Application\Contracts\TaskImageFiles;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskUsage;
|
||||
use App\Modules\Jobs\Domain\Contracts\TaskImageRepository;
|
||||
use App\Modules\Jobs\Domain\Contracts\TaskRepository;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TaskHasTimeEntries;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
||||
use App\Modules\Shared\Application\Contracts\TransactionManager;
|
||||
|
||||
/**
|
||||
* Deletes a task that has no time entries.
|
||||
* Deletes a task that has no time entries, and then its images' files.
|
||||
*/
|
||||
final class RemoveTask
|
||||
{
|
||||
@@ -19,6 +21,8 @@ final class RemoveTask
|
||||
private TaskRepository $tasks,
|
||||
private TaskUsage $usage,
|
||||
private TransactionManager $transactions,
|
||||
private TaskImageRepository $images,
|
||||
private TaskImageFiles $imageFiles,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -27,14 +31,19 @@ final class RemoveTask
|
||||
*/
|
||||
public function execute(int $jobId, int $taskId): void
|
||||
{
|
||||
$this->transactions->run(function () use ($jobId, $taskId): void {
|
||||
$imagePaths = $this->transactions->run(function () use ($jobId, $taskId): array {
|
||||
$task = $this->tasks->findForJob($jobId, $taskId) ?? throw new TaskNotFound($jobId, $taskId);
|
||||
|
||||
if ($this->usage->hasTimeEntries($taskId)) {
|
||||
throw new TaskHasTimeEntries;
|
||||
}
|
||||
|
||||
$imagePaths = $this->images->filePathsOfTask($taskId);
|
||||
$this->tasks->delete($task);
|
||||
|
||||
return $imagePaths;
|
||||
});
|
||||
|
||||
$this->imageFiles->delete($imagePaths);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user