1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/database/migrations/2022_11_16_093535_calmness_design.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2022-11-16 10:57:08 +01:00
<?php
use App\Models\Design;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Services\PdfMaker\Design as PdfMakerDesign;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$design_array = ['name' => 'Calm', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true];
2022-11-16 10:57:08 +01:00
$design = Design::where('name', 'Calm')->whereNull('company_id')->first();
if(!$design)
$design = Design::create($design_array);
2022-11-16 10:57:08 +01:00
$template = new PdfMakerDesign(strtolower($design->name));
$template->document();
$design_object = new \stdClass;
$design_object->includes = $template->getSectionHTML('style');
$design_object->header = $template->getSectionHTML('header');
$design_object->body = $template->getSectionHTML('body');
$design_object->product = '';
$design_object->task = '';
$design_object->footer = $template->getSectionHTML('footer');
$design->design = $design_object;
$design->save();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};