feat: add insight timer

This commit is contained in:
2026-06-03 00:55:40 +03:30
parent 82164f691f
commit 6f01c783fd
13 changed files with 599 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Bell sounds used for start / end / interval bells (زنگ شروع/پایان/بین‌راهی).
Schema::create('bell_sounds', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('sound_path')->nullable();
$table->string('image_path')->nullable();
$table->integer('order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('bell_sounds');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Ambient background sounds (صدای پس‌زمینه).
Schema::create('background_sounds', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('sound_path')->nullable();
$table->string('image_path')->nullable();
$table->integer('order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('background_sounds');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Background images (تصویر پس‌زمینه).
Schema::create('background_images', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('image_path')->nullable();
$table->integer('order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('background_images');
}
};
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// A saved meditation timer (ذخیره‌شده‌های من) configured by a user.
Schema::create('timer_presets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->string('name');
$table->unsignedInteger('duration_seconds')->default(0); // مدت زمان
// Bells
$table->foreignId('start_bell_id')->nullable()->constrained('bell_sounds')->nullOnDelete();
$table->foreignId('end_bell_id')->nullable()->constrained('bell_sounds')->nullOnDelete();
$table->foreignId('interval_bell_id')->nullable()->constrained('bell_sounds')->nullOnDelete();
$table->unsignedInteger('interval_seconds')->nullable(); // هر چند ثانیه یک‌بار
$table->unsignedInteger('interval_repeat')->nullable(); // تکرار چند بار
// Ambience
$table->foreignId('background_sound_id')->nullable()->constrained('background_sounds')->nullOnDelete();
$table->foreignId('background_image_id')->nullable()->constrained('background_images')->nullOnDelete();
$table->unsignedInteger('volume')->default(100); // صدای دستگاه (0-100)
$table->timestamps();
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('timer_presets');
}
};
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Repoint timer background image to the shared `images` table and drop the
* dedicated background_images catalog.
*/
public function up(): void
{
Schema::table('timer_presets', function (Blueprint $table) {
$table->dropForeign(['background_image_id']);
});
Schema::dropIfExists('background_images');
Schema::table('timer_presets', function (Blueprint $table) {
$table->foreign('background_image_id')->references('id')->on('images')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('timer_presets', function (Blueprint $table) {
$table->dropForeign(['background_image_id']);
});
Schema::create('background_images', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('image_path')->nullable();
$table->integer('order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
Schema::table('timer_presets', function (Blueprint $table) {
$table->foreign('background_image_id')->references('id')->on('background_images')->nullOnDelete();
});
}
};