Files
back-meditation/database/seeders/BreathingTemplateSeeder.php
T

102 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\BreathingTemplate;
use Illuminate\Support\Facades\DB;
class BreathingTemplateSeeder extends Seeder
{
public function run(): void
{
BreathingTemplate::query()->delete();
// تشخیص نوع دیتابیس
$driver = DB::getDriverName();
if ($driver === 'mysql') {
// ریست Auto Increment در MySQL
DB::statement('ALTER TABLE breathing_templates AUTO_INCREMENT = 1');
} elseif ($driver === 'pgsql') {
// ریست Sequence در PostgreSQL
DB::statement('ALTER SEQUENCE breathing_templates_id_seq RESTART WITH 1');
}
$templates = [
[
'name' => '۴-۷-۸ تنفس آرام',
'inhale' => 4,
'exhale' => 8,
'breath_hold' => 7,
'duration' => 60
],
[
'name' => 'تنفس جعبه‌ای (Box Breathing)',
'inhale' => 4,
'exhale' => 4,
'breath_hold' => 4,
'duration' => 60
],
[
'name' => 'تنفس هماهنگ (Coherent Breathing)',
'inhale' => 5,
'exhale' => 5,
'breath_hold' => 0,
'duration' => 60
],
[
'name' => 'تنفس آرام عمیق',
'inhale' => 6,
'exhale' => 6,
'breath_hold' => 0,
'duration' => 90
],
[
'name' => 'تنفس تمرکزی ساده',
'inhale' => 4,
'exhale' => 4,
'breath_hold' => 0,
'duration' => 60
],
[
'name' => 'تنفس برای کاهش استرس',
'inhale' => 5,
'exhale' => 7,
'breath_hold' => 0,
'duration' => 120
],
[
'name' => 'تنفس پاکسازی',
'inhale' => 3,
'exhale' => 5,
'breath_hold' => 0,
'duration' => 60
],
[
'name' => 'تنفس ذهنی کوتاه',
'inhale' => 4,
'exhale' => 4,
'breath_hold' => 0,
'duration' => 30
],
[
'name' => 'تنفس خواب‌آور ۴-۷-۸',
'inhale' => 4,
'exhale' => 8,
'breath_hold' => 7,
'duration' => 120
],
[
'name' => 'تنفس تجدید انرژی',
'inhale' => 2,
'exhale' => 4,
'breath_hold' => 0,
'duration' => 45
],
];
foreach ($templates as $template) {
BreathingTemplate::create($template);
}
}
}