Skip to content

Commit 8cc054f

Browse files
authored
Fix file download
1 parent 11932f4 commit 8cc054f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Controllers/ModelController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ public function download($slug, $id, $column, $data)
180180
$this->checkSlug($slug, 'read');
181181
$row = @$this->model()::findOrFail($id, $this->filter_pivot($this->columns()))->getOriginal();
182182
abort_if(empty($row[$column]), 404);
183-
$array = json_decode($row[$column]);
184-
abort_if(empty($array->$data) || !isset($array->$data->name) || !isset($array->$data->type) || !isset($array->$data->size) || !isset($array->$data->store), 404);
185-
$file = rtrim($this->columns('data')['storage_path'] ?? storage_path(), '/') . '/' . $array->$data->store;
186-
abort_if(!file_exists($file), 404);
187-
return response()->download($file, $array->$data->name);
183+
$file = (object)$row[$column][$data];
184+
abort_if(empty($file) || !isset($file->name) || !isset($file->type) || !isset($file->size) || !isset($file->store), 404);
185+
$file_path = rtrim($this->columns('data')['storage_path'] ?? storage_path(), '/') . '/' . $file->store;
186+
abort_if(!file_exists($file_path), 404);
187+
return response()->download($file_path, $file->name);
188188
}
189189

190190
/**

0 commit comments

Comments
 (0)