controller refactoring part 24

This commit is contained in:
Peter Papp
2021-07-21 18:14:23 +02:00
parent 91cb795054
commit 54f1f4c9a8
18 changed files with 136 additions and 138 deletions

View File

@@ -1,31 +1,33 @@
<?php
namespace Domain\Files\Controllers\FileAccess;
use App\Http\Controllers\Controller;
use Domain\Files\Models\File as UserFile;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Domain\Files\Models\File as UserFile;
use Domain\Files\Actions\DownloadThumbnailAction;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
class GetThumbnailController extends Controller
{
public function __construct(
private DownloadThumbnailAction $downloadThumbnail,
) {
}
/**
* Get image thumbnail
*/
public function __invoke(
Request $request,
string $filename,
): FileNotFoundException|StreamedResponse {
): FileNotFoundException | StreamedResponse {
$file = UserFile::withTrashed()
->whereUserId(Auth::id())
->whereThumbnail($filename)
->firstOrFail();
return $this->helper->download_thumbnail_file($file, Auth::id());
return ($this->downloadThumbnail)($file, Auth::id());
}
}
}