79 lines
2.1 KiB
PHP
79 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
class CreatePalettesTable extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('palettes', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->string('name');
|
||
|
$table->timestamps();
|
||
|
});
|
||
|
|
||
|
Schema::create('palette_colors', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->foreignId('palette_id')->constrained()->onDelete('cascade');
|
||
|
$table->string('name');
|
||
|
$table->string('hex_value');
|
||
|
$table->timestamps();
|
||
|
});
|
||
|
|
||
|
// Insert default palette
|
||
|
DB::table('palettes')->insert([
|
||
|
'name' => 'default-colors',
|
||
|
'created_at' => now(),
|
||
|
'updated_at' => now(),
|
||
|
]);
|
||
|
|
||
|
$defaultColors = [
|
||
|
["white", "#FFFFFF"],
|
||
|
["light-gray", "#E4E4E4"],
|
||
|
["medium-gray", "#888888"],
|
||
|
["dark-gray", "#222222"],
|
||
|
["pink", "#FFA7D1"],
|
||
|
["red", "#E50000"],
|
||
|
["orange", "#E59500"],
|
||
|
["brown", "#A06A42"],
|
||
|
["yellow", "#E5D900"],
|
||
|
["light-green", "#94E044"],
|
||
|
["green", "#02BE01"],
|
||
|
["cyan", "#00D3DD"],
|
||
|
["blue", "#0083C7"],
|
||
|
["dark-blue", "#0000EA"],
|
||
|
["purple", "#CF6EE4"],
|
||
|
["dark-purple", "#820080"],
|
||
|
["black", "#000000"]
|
||
|
];
|
||
|
|
||
|
foreach ($defaultColors as $color) {
|
||
|
DB::table('palette_colors')->insert([
|
||
|
'palette_id' => 1,
|
||
|
'name' => $color[0],
|
||
|
'hex_value' => $color[1],
|
||
|
'created_at' => now(),
|
||
|
'updated_at' => now(),
|
||
|
]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::dropIfExists('palette_colors');
|
||
|
Schema::dropIfExists('palettes');
|
||
|
}
|
||
|
}
|