mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
deleting attachments when master / sub task is deleted
This commit is contained in:
1 parent
17ed7616ee
commit
f35cd29071
4 files changed
+59
-3
No files matched your search
@@ -47,4 +47,12 @@ class Attachment extends Model
|
||||
|
||||
return $attachmentDataArray;
|
||||
}
|
||||
|
||||
public function deleteFromS3()
|
||||
{
|
||||
$path = 'jandl_taskmanager/attachments/' . $this->master_task_id . '/' . $this->disk_name;
|
||||
Storage::disk('s3')->delete($path);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -53,4 +53,15 @@ class MasterTask extends Model
|
||||
// return random value from array
|
||||
return collect(['#E9FFE5', '#F6ECD3', '#FDE1FF', '#FFC9C9', '#DADEF8', '#EDFFFE'])->random();
|
||||
}
|
||||
|
||||
public function deleteAttachments()
|
||||
{
|
||||
foreach ( $this->attachments as $attachment ) {
|
||||
$attachment->deleteFromS3();
|
||||
}
|
||||
|
||||
$this->attachments()->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user