2018-02-01 07:47:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\ProposalTemplate;
|
|
|
|
|
|
|
|
class ProposalTemplatesSeeder extends Seeder
|
|
|
|
{
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
Eloquent::unguard();
|
|
|
|
|
|
|
|
$designs = [
|
|
|
|
'Clean',
|
|
|
|
'Bold',
|
|
|
|
'Modern',
|
|
|
|
'Plain',
|
|
|
|
'Business',
|
|
|
|
'Creative',
|
|
|
|
'Elegant',
|
|
|
|
'Hipster',
|
|
|
|
'Playful',
|
|
|
|
'Photo',
|
|
|
|
];
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($designs); $i++) {
|
|
|
|
$design = $designs[$i];
|
2018-02-12 13:30:27 +01:00
|
|
|
$baseFileName = storage_path() . '/templates/' . strtolower($design);
|
|
|
|
$htmlFileName = $baseFileName . '.html';
|
|
|
|
$cssFileName = $baseFileName . '.css';
|
|
|
|
if (file_exists($htmlFileName) && file_exists($cssFileName)) {
|
2018-02-12 20:21:49 +01:00
|
|
|
$template = ProposalTemplate::whereName($design)->whereNull('account_id')->first();
|
2018-02-01 07:47:17 +01:00
|
|
|
|
2018-02-12 13:30:27 +01:00
|
|
|
if (! $template) {
|
|
|
|
$template = new ProposalTemplate();
|
|
|
|
$template->public_id = $i + 1;
|
|
|
|
$template->name = $design;
|
|
|
|
}
|
2018-02-01 07:47:17 +01:00
|
|
|
|
2018-02-12 13:30:27 +01:00
|
|
|
$template->html = file_get_contents($htmlFileName);
|
|
|
|
$template->css = file_get_contents($cssFileName);
|
|
|
|
$template->save();
|
2018-02-01 07:47:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|