feat: add breath colors
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('breathing_templates', function (Blueprint $table) {
|
||||
// One or more hex colors: a single solid color or a gradient.
|
||||
$table->json('colors')->nullable()->after('image_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('breathing_templates', function (Blueprint $table) {
|
||||
$table->dropColumn('colors');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('breathing_colors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->json('colors'); // one hex (solid) or several (gradient)
|
||||
$table->integer('order')->default(0);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('breathing_colors');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('breathing_templates', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('breathing_templates', 'colors')) {
|
||||
$table->dropColumn('colors');
|
||||
}
|
||||
$table->foreignId('breathing_color_id')->nullable()->after('image_id')
|
||||
->constrained('breathing_colors')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('breathing_templates', function (Blueprint $table) {
|
||||
$table->dropForeign(['breathing_color_id']);
|
||||
$table->dropColumn('breathing_color_id');
|
||||
$table->json('colors')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\BreathingColor;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class BreathingColorSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$colors = [
|
||||
['name' => 'آبی', 'order' => 1, 'colors' => ['#3ABDEB', '#553AEB']],
|
||||
['name' => 'صورتی', 'order' => 2, 'colors' => ['#CE4299', '#8628FF']],
|
||||
['name' => 'سبز', 'order' => 3, 'colors' => ['#5CC65C', '#00A489']],
|
||||
['name' => 'نارنجی', 'order' => 4, 'colors' => ['#E2990A', '#CC4B1C']],
|
||||
['name' => 'بنفش', 'order' => 5, 'colors' => ['#6829DD', '#1A50CC']],
|
||||
['name' => 'تکرنگ', 'order' => 6, 'colors' => ['#5360FC']],
|
||||
];
|
||||
|
||||
foreach ($colors as $c) {
|
||||
BreathingColor::firstOrCreate(['name' => $c['name']], $c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user