|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use App\Model\Page; |
|
4
|
|
|
use Illuminate\Support\Facades\Schema; |
|
5
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
6
|
|
|
use App\Plugins\Newsletters\Model\Newsletter; |
|
7
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
8
|
|
|
|
|
9
|
|
|
class MarchUpdateOne extends Migration |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Run the migrations. |
|
13
|
|
|
* |
|
14
|
|
|
* @return void |
|
15
|
|
|
*/ |
|
16
|
|
|
public function up() |
|
17
|
|
|
{ |
|
18
|
|
|
$plugin = new \App\Model\Plugin(); |
|
19
|
|
|
|
|
20
|
|
|
$plugin->setAttribute('name', 'newsletters'); |
|
21
|
|
|
$plugin->setAttribute('enabled', false); |
|
22
|
|
|
$plugin->setAttribute('is_frontend', true); |
|
23
|
|
|
$plugin->setAttribute('is_backend', true); |
|
24
|
|
|
$plugin->setAttribute('required', false); |
|
25
|
|
|
$plugin->save(); |
|
26
|
|
|
|
|
27
|
|
|
Schema::create('newsletters', function (Blueprint $table) { |
|
28
|
|
|
$table->increments('id'); |
|
29
|
|
|
$table->string('title'); |
|
30
|
|
|
$table->string('content'); |
|
31
|
|
|
$table->integer('emailCount'); |
|
32
|
|
|
$table->boolean('deliveryStatus'); |
|
33
|
|
|
$table->integer('editor_id'); |
|
34
|
|
|
$table->integer('creator_id'); |
|
35
|
|
|
$table->timestamps(); |
|
36
|
|
|
}); |
|
37
|
|
|
|
|
38
|
|
|
Schema::create('newsletter_users', function (Blueprint $table) { |
|
39
|
|
|
$table->increments('id'); |
|
40
|
|
|
$table->string('email', 191)->unique(); |
|
41
|
|
|
$table->timestamps(); |
|
42
|
|
|
}); |
|
43
|
|
|
|
|
44
|
|
|
Schema::create('newsletter_templates', function (Blueprint $table) { |
|
45
|
|
|
$table->increments('id'); |
|
46
|
|
|
$table->integer('editor_id'); |
|
47
|
|
|
$table->integer('creator_id'); |
|
48
|
|
|
$table->softDeletes(); |
|
49
|
|
|
$table->timestamps(); |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
Schema::table('pages', function (Blueprint $table) { |
|
53
|
|
|
$table->string('identifier')->nullable()->after('id')->index(); |
|
54
|
|
|
$table->boolean('special')->default(0)->after('editable'); |
|
55
|
|
|
}); |
|
56
|
|
|
|
|
57
|
|
|
/** @var Page $page */ |
|
58
|
|
|
$page = app(Page::class); |
|
59
|
|
|
$page->setAttribute('identifier', Newsletter::VIEW_NEWSLETTER_SUCCESS); |
|
60
|
|
|
$page->setAttribute('title', 'Thank You Newsletter'); |
|
61
|
|
|
$page->setAttribute('content', '<h1>Newsletter Signup Complete</h1> <p>Thank you for subscribing to our newsletter.</p>'); |
|
62
|
|
|
$page->setAttribute('editable', true); |
|
63
|
|
|
$page->setAttribute('special', true); |
|
64
|
|
|
$page->setAttribute('sitemap', false); |
|
65
|
|
|
$page->setAttribute('enabled', true); |
|
66
|
|
|
$page->save(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Reverse the migrations. |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function down() |
|
75
|
|
|
{ |
|
76
|
|
|
// |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.