| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function __invoke($id, $name) |
||
| 16 | { |
||
| 17 | // Make sure that the file actually exists in the database - both file ID and name must match |
||
| 18 | $file = FileUploads::where('file_id', $id)->where('file_name', $name)->firstOrFail(); |
||
| 19 | |||
| 20 | // Determine if the person downloading the file is allowed to download it |
||
| 21 | if(!Auth::check() && !$file->public) |
||
| 22 | { |
||
| 23 | abort(403, 'You Do Not Have Permission To Download This File'); |
||
| 24 | } |
||
| 25 | |||
| 26 | // Determine that the file itself exists |
||
| 27 | if(!Storage::disk($file->disk)->exists($file->folder.DIRECTORY_SEPARATOR.$file->file_name)) |
||
| 28 | { |
||
| 29 | abort(404, 'Cannot Find the File Specified'); |
||
| 30 | } |
||
| 31 | |||
| 32 | return Storage::disk($file->disk)->download($file->folder.DIRECTORY_SEPARATOR.$file->file_name); |
||
| 33 | } |
||
| 35 |