Skip to content

Commit b3c8cd1

Browse files
committed
fixes cascadable
1 parent 3ee9382 commit b3c8cd1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Http/Controllers/File/Destroy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public function __invoke(File $file)
1515
{
1616
$this->authorize('manage', $file);
1717

18-
DB::transaction(fn () => $file->delete());
18+
DB::transaction(fn () => $file->delete(true));
1919
}
2020
}

src/Models/File.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ public static function upload(Attachable $attachable, UploadedFile $file): self
141141
return (new Upload($attachable, $file))->handle();
142142
}
143143

144-
public function delete()
144+
public function delete(bool $cascadable = false)
145145
{
146-
$cascadesDeletion = (new ReflectionClass($this->type->model))
146+
$cascadesDeletion = $cascadable
147+
&& (new ReflectionClass($this->type->model))
147148
->implementsInterface(CascadesFileDeletion::class);
148149

149150
if ($cascadesDeletion) {

0 commit comments

Comments
 (0)