file route for template generation

This commit is contained in:
2024-09-13 17:16:04 +03:00
parent f868219981
commit c0b3878674
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -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();