Skip to content

Commit 28d5d24

Browse files
committed
Migration to handle skins
1 parent d97f690 commit 28d5d24

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
use Illuminate\Support\Facades\DB;
7+
8+
return new class extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*/
13+
public function up(): void
14+
{
15+
$setting = DB::table('settings')->select(['skin'])->first();
16+
17+
18+
Schema::table('settings', function (Blueprint $table) {
19+
$table->string('link_dark_color')->after('header_color')->nullable()->default(null);
20+
$table->string('link_light_color')->after('header_color')->nullable()->default(null);
21+
});
22+
23+
24+
25+
$link_dark_color = '#36aff5';
26+
$link_light_color = '#3c8dbc';
27+
28+
switch ($setting->skin) {
29+
case 'green':
30+
$link_dark_color = '#00a65a';
31+
$link_light_color = '#00a65a';
32+
case 'green-dark':
33+
$link_dark_color = '#00a65a';
34+
$link_light_color = '#00a65a';
35+
case 'red':
36+
$link_dark_color = '#dd4b39';
37+
$link_light_color = '#dd4b39';
38+
case 'red-dark':
39+
$link_dark_color = '#dd4b39';
40+
$link_light_color = '#dd4b39';
41+
case 'orange':
42+
$link_dark_color = '#FF851B';
43+
$link_light_color = '#FF851B';
44+
case 'orange-dark':
45+
$link_dark_color = '#FF8C00';
46+
$link_light_color = '#FF8C00';
47+
case 'black':
48+
$link_dark_color = '#111';
49+
$link_light_color = '#111';
50+
case 'black-dark':
51+
$link_dark_color = '#111';
52+
$link_light_color = '#111';
53+
case 'purple':
54+
$link_dark_color = '#605ca8';
55+
$link_light_color = '#605ca8';
56+
case 'purple-dark':
57+
$link_dark_color = '#605ca8';
58+
$link_light_color = '#605ca8';
59+
case 'yellow':
60+
$link_dark_color = '#f39c12';
61+
$link_light_color = '#f39c12';
62+
case 'yellow-dark':
63+
$link_dark_color = '#f39c12';
64+
$link_light_color = '#f39c12';
65+
case 'contrast':
66+
$link_dark_color = '#86cbf2';
67+
$link_light_color = '#084d73';
68+
}
69+
70+
DB::table('settings')->update(['link_light_color' => $link_light_color, 'link_dark_color' => $link_dark_color]);
71+
72+
73+
74+
}
75+
76+
/**
77+
* Reverse the migrations.
78+
*/
79+
public function down(): void
80+
{
81+
Schema::table('settings', function ($table) {
82+
$table->dropColumn('link_dark_color');
83+
$table->dropColumn('link_light_color');
84+
});
85+
}
86+
};

0 commit comments

Comments
 (0)