1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 11:12:43 +01:00
invoiceninja/database/seeds/DesignSeeder.php
David Bomba 7acc6ee300
Repeating header and footers on Invoice PDFs (#3424)
* remove jobs table

* Working on notifications

* Working on notifications

* Fixes for setting group level currency id on new client

* Working on repeating headers

* Use CSS to force headers and footers

* recurring headers and footers

* Preview PDF

* Working on PDF Preview
2020-03-05 18:14:57 +11:00

58 lines
2.6 KiB
PHP

<?php
use App\Models\Bank;
use App\Models\Design;
use Illuminate\Database\Seeder;
class DesignSeeder extends Seeder
{
public function run()
{
Eloquent::unguard();
$this->createDesigns();
}
private function createDesigns()
{
$designs = [
['id' => 1, 'name' => 'Plain', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 2, 'name' => 'Clean', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 3, 'name' => 'Bold', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 4, 'name' => 'Modern', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 5, 'name' => 'Business', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 6, 'name' => 'Creative', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 7, 'name' => 'Elegant', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 8, 'name' => 'Hipster', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 9, 'name' => 'Playful', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 10, 'name' => 'Photo', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
];
foreach($designs as $design) {
$d = Design::find($design['id']);
if(!$d)
Design::create($design);
}
foreach(Design::all() as $design){
$class = 'App\Designs\\'.$design->name;
$invoice_design = new $class();
$design_object = new \stdClass;
$design_object->include = $invoice_design->include();
$design_object->header = $invoice_design->header();
$design_object->body = $invoice_design->body();
$design_object->table_styles = $invoice_design->table_styles();
$design_object->product_table = $invoice_design->product_table();
$design_object->task_table = $invoice_design->task_table();
$design_object->footer = $invoice_design->footer();
$design->design = $design_object;
$design->save();
}
}
}