Skip to content

Commit

Permalink
add responseFile method
Browse files Browse the repository at this point in the history
  • Loading branch information
kolirt committed Oct 20, 2024
1 parent 4f36578 commit 328a01e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"homepage": "https://github.com/kolirt/laravel-master-model",
"license": "MIT",
"version": "4.0.2",
"version": "4.0.3",
"authors": [
{
"name": "kolirt"
Expand Down
18 changes: 8 additions & 10 deletions src/Traits/MasterModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,17 @@ private function getDisk($key = null): string
return $this->upload_disks[$key] ?? config('master-model.files.disk');
}

/*private function hasUploadedFile(array $attributes): bool
public function responseFile(string $key, $name = null, array $headers = [], $disposition = 'inline')
{
foreach ($attributes as $value) {
if ($value instanceof UploadedFile) {
return true;
}
}
return false;
}*/
$value = $this->getAttributeValue($key);

public function getImage()
{
if (is_stored_file($value)) {
[$disk_name, $stored_file_path] = explode(':', $value);
return Storage::disk($disk_name)->response($stored_file_path, $name, $headers, $disposition);
}

abort(404);
}


}

0 comments on commit 328a01e

Please sign in to comment.