feat: breath template & breath session
This commit is contained in:
@@ -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()
|
||||
{
|
||||
Schema::create('breathing_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->onDelete('cascade'); // null = default template
|
||||
$table->string('name');
|
||||
$table->integer('inhale');
|
||||
$table->integer('exhale');
|
||||
$table->integer('repeat');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('breathing_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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()
|
||||
{
|
||||
Schema::create('user_breathing_sessions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('template_id')->constrained('breathing_templates')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_breathing_sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\BreathingTemplate;
|
||||
|
||||
class BreathingTemplateSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$templates = [
|
||||
['name' => 'نفس آرام', 'inhale' => 4, 'exhale' => 4, 'repeat' => 5],
|
||||
['name' => 'نفس تمرکزی', 'inhale' => 3, 'exhale' => 3, 'repeat' => 8],
|
||||
['name' => 'نفس تسکین دهنده', 'inhale' => 6, 'exhale' => 6, 'repeat' => 10],
|
||||
['name' => 'نفس انرژی بخش', 'inhale' => 2, 'exhale' => 2, 'repeat' => 12],
|
||||
['name' => 'نفس عمیق', 'inhale' => 5, 'exhale' => 5, 'repeat' => 7],
|
||||
['name' => 'نفس آرامش بخش', 'inhale' => 4, 'exhale' => 6, 'repeat' => 6],
|
||||
['name' => 'نفس پاکسازی', 'inhale' => 3, 'exhale' => 5, 'repeat' => 8],
|
||||
['name' => 'نفس ذهنی', 'inhale' => 4, 'exhale' => 4, 'repeat' => 9],
|
||||
['name' => 'نفس کنترل استرس', 'inhale' => 5, 'exhale' => 7, 'repeat' => 6],
|
||||
['name' => 'نفس تمرینی', 'inhale' => 3, 'exhale' => 4, 'repeat' => 10],
|
||||
];
|
||||
|
||||
foreach ($templates as $template) {
|
||||
BreathingTemplate::create($template);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,20 @@
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
$this->call([
|
||||
BreathingTemplateSeeder::class,
|
||||
]);
|
||||
// User::factory()->create([
|
||||
// 'name' => 'Test User',
|
||||
// 'email' => 'test@example.com',
|
||||
// ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user