Поддержка тегов шаблонами

This commit is contained in:
brusnitsyn
2025-11-05 16:30:24 +09:00
parent 3e62e0f36d
commit 66d2168836
3 changed files with 37 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ class DocImportController extends Controller
'description' => $template->description, 'description' => $template->description,
'file_url' => $urlFile, 'file_url' => $urlFile,
'variables' => $template->variables, 'variables' => $template->variables,
'tags' => $template->tags
]); ]);
} }
@@ -35,6 +36,7 @@ class DocImportController extends Controller
'name' => 'nullable|string|max:255', 'name' => 'nullable|string|max:255',
'description' => 'nullable|string', 'description' => 'nullable|string',
'variables' => 'nullable|array', 'variables' => 'nullable|array',
'tags' => 'nullable|array',
]); ]);
$template = DocumentTemplate::findOrFail($data['id']); $template = DocumentTemplate::findOrFail($data['id']);
@@ -53,6 +55,7 @@ class DocImportController extends Controller
'name' => $data['name'], 'name' => $data['name'],
'description' => $data['description'], 'description' => $data['description'],
'variables' => $data['variables'], 'variables' => $data['variables'],
'tags' => $data['tags'] ?? [],
]); ]);
} }
@@ -63,6 +66,7 @@ class DocImportController extends Controller
'name' => 'nullable|string|max:255', 'name' => 'nullable|string|max:255',
'description' => 'nullable|string', 'description' => 'nullable|string',
'variables' => 'nullable|array', 'variables' => 'nullable|array',
'tags' => 'nullable|array',
]); ]);
$file = $request->file('file'); $file = $request->file('file');
@@ -77,6 +81,7 @@ class DocImportController extends Controller
'content' => 'content', 'content' => 'content',
'variables' => $data['variables'] ?? [], 'variables' => $data['variables'] ?? [],
'source_path' => "storage/$laravelPath" . '/' . $templateFileName, 'source_path' => "storage/$laravelPath" . '/' . $templateFileName,
'tags' => $data['tags'] ?? [],
]); ]);
} }

View File

@@ -13,11 +13,13 @@ class DocumentTemplate extends Model
'description', 'description',
'content', 'content',
'variables', 'variables',
'source_path' 'source_path',
'tags'
]; ];
protected $casts = [ protected $casts = [
'variables' => 'array' 'variables' => 'array',
'tags' => 'array',
]; ];
/** /**

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('document_templates', function (Blueprint $table) {
$table->json('tags')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('document_templates', function (Blueprint $table) {
$table->dropColumn('tags');
});
}
};