solve template issue

This commit is contained in:
jayvirsinh_gohil
2021-12-02 14:46:53 +05:30
parent 7a45ed0982
commit 887d5d0685
2 changed files with 46 additions and 0 deletions

View File

@ -53,6 +53,7 @@ class CreateTemplateCommand extends Command
Storage::disk('views')->copy("/app/pdf/{$type}/{$type}1.blade.php", "/app/pdf/{$type}/{$templateName}.blade.php");
copy(public_path("/build/img/PDF/{$type}1.png"), public_path("/build/img/PDF/{$templateName}.png"));
copy(resource_path("/static/img/PDF/{$type}1.png"), resource_path("/static/img/PDF/{$templateName}.png"));
$path = resource_path("app/pdf/{$type}/{$templateName}.blade.php");
$type = ucfirst($type);

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
class MigrateTemplatesFromVersion4 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$templates = Storage::disk('views')->files('/app/pdf/invoice');
foreach ($templates as $key => $template) {
$templateName = Str::before(basename($template), '.blade.php');
if (! file_exists(resource_path("/static/img/PDF/{$templateName}.png"))) {
copy(public_path("/assets/img/PDF/{$templateName}.png"), public_path("/build/img/PDF/{$templateName}.png"));
copy(public_path("/assets/img/PDF/{$templateName}.png"), resource_path("/static/img/PDF/{$templateName}.png"));
}
}
$templates = Storage::disk('views')->files('/app/pdf/estimate');
foreach ($templates as $key => $template) {
$templateName = Str::before(basename($template), '.blade.php');
if (! file_exists(resource_path("/static/img/PDF/{$templateName}.png"))) {
copy(public_path("/assets/img/PDF/{$templateName}.png"), public_path("/build/img/PDF/{$templateName}.png"));
copy(public_path("/assets/img/PDF/{$templateName}.png"), resource_path("/static/img/PDF/{$templateName}.png"));
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}