Skip to content

Commit e6c030b

Browse files
authored
Merge pull request #17781 from grokability/#17780-add-withtrashed-to-files
Fixed #17780 - Added `withTrashed()` to allow viewing files on deleted objects
2 parents b9cfc03 + 7bd3a79 commit e6c030b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/Http/Controllers/Api/UploadedFilesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function index(Request $request, $object_type, $id) : JsonResponse | arra
3232
{
3333

3434
// Check the permissions to make sure the user can view the object
35-
$object = self::$map_object_type[$object_type]::find($id);
35+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
3636
$this->authorize('view', $object);
3737

3838
if (!$object) {
@@ -96,7 +96,7 @@ public function store(UploadFileRequest $request, $object_type, $id) : JsonRespo
9696
{
9797

9898
// Check the permissions to make sure the user can view the object
99-
$object = self::$map_object_type[$object_type]::find($id);
99+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
100100
$this->authorize('view', $object);
101101

102102
if (!$object) {
@@ -144,7 +144,7 @@ public function store(UploadFileRequest $request, $object_type, $id) : JsonRespo
144144
public function show($object_type, $id, $file_id) : JsonResponse | StreamedResponse | Storage | StorageHelper | BinaryFileResponse
145145
{
146146
// Check the permissions to make sure the user can view the object
147-
$object = self::$map_object_type[$object_type]::find($id);
147+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
148148
$this->authorize('view', $object);
149149

150150
if (!$object) {
@@ -188,7 +188,7 @@ public function destroy($object_type, $id, $file_id) : JsonResponse
188188
{
189189

190190
// Check the permissions to make sure the user can view the object
191-
$object = self::$map_object_type[$object_type]::find($id);
191+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
192192
$this->authorize('update', self::$map_object_type[$object_type]);
193193

194194
if (!$object) {

app/Http/Controllers/UploadedFilesController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function store(UploadFileRequest $request, $object_type, $id) : RedirectR
3636
{
3737

3838
// Check the permissions to make sure the user can view the object
39-
$object = self::$map_object_type[$object_type]::find($id);
39+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
4040
$this->authorize('update', $object);
4141

4242
if (!$object) {
@@ -85,7 +85,7 @@ public function store(UploadFileRequest $request, $object_type, $id) : RedirectR
8585
public function show($object_type, $id, $file_id) : RedirectResponse | StreamedResponse | Storage | StorageHelper | BinaryFileResponse
8686
{
8787
// Check the permissions to make sure the user can view the object
88-
$object = self::$map_object_type[$object_type]::find($id);
88+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
8989
$this->authorize('view', $object);
9090

9191
if (!$object) {
@@ -130,7 +130,7 @@ public function destroy($object_type, $id, $file_id) : RedirectResponse
130130
{
131131

132132
// Check the permissions to make sure the user can view the object
133-
$object = self::$map_object_type[$object_type]::find($id);
133+
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
134134
$this->authorize('update', self::$map_object_type[$object_type]);
135135

136136
if (!$object) {

0 commit comments

Comments
 (0)