diff --git a/src/Http/Controller/FileController.php b/src/Http/Controller/FileController.php index f27dd45..f0e4523 100644 --- a/src/Http/Controller/FileController.php +++ b/src/Http/Controller/FileController.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use Lucent\Channel\ChannelService; use Lucent\File\FileService; +use Lucent\File\ImageService; use Lucent\Query\Query; use Lucent\Record\InputData\RecordInputData; use Lucent\Record\RecordService; @@ -22,11 +23,23 @@ class FileController extends Controller private readonly ChannelService $channelService, private readonly RecordService $recordService, private readonly FileService $fileService, + private readonly ImageService $imageService, private readonly Query $query ) { } + public function template(Request $request) + { + $template = $request->segment(3); + $templatePath = $request->route("any"); + $filePath = str_replace($template."/", "", $templatePath); + $record = $this->query->filter(["_file.path" => $filePath])->run()->records->first(); + $this->imageService->file($record,$template); + $disk = $this->fileService->loadDisk(); + return response()->file($disk->path("templates/".$templatePath)); + } + public function download(Request $request) { $disk = $this->fileService->loadDisk(); diff --git a/src/Http/web.php b/src/Http/web.php index b71e12b..9e8ce92 100644 --- a/src/Http/web.php +++ b/src/Http/web.php @@ -14,6 +14,7 @@ use Lucent\Http\Controller\SetupController; Route::get('/lucent/setup', [SetupController::class, 'setup']); +Route::get('/storage/templates/{any}', [FileController::class, 'template'])->where('any', '.*'); Route::group([ 'middleware' => ['web'],