feat: add mood

This commit is contained in:
2025-08-27 13:45:21 +03:30
parent 8f9829fc1f
commit 01b67d8f80
8 changed files with 197 additions and 14 deletions
@@ -11,8 +11,11 @@
*/
public function up(): void
{
Schema::create('user_mood', function (Blueprint $table) {
Schema::create('moods', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description')->nullable();
$table->string('emoji');
$table->timestamps();
});
}
@@ -22,6 +25,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists('user_mood');
Schema::dropIfExists('moods');
}
};
@@ -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(): void
{
Schema::create('user_moods', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->foreignId('mood_id')->constrained('moods')->onDelete('cascade');
$table->date('date');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_moods');
}
};
+15 -12
View File
@@ -8,20 +8,23 @@
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call(MoodSeeder::class);
}
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
$this->call([
BreathingTemplateSeeder::class,
]);
// User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
}
// public function run(): void
// {
// // User::factory(10)->create();
// $this->call([
// BreathingTemplateSeeder::class,
// ]);
// // User::factory()->create([
// // 'name' => 'Test User',
// // 'email' => 'test@example.com',
// // ]);
// }
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Mood;
class MoodSeeder extends Seeder
{
public function run()
{
$moods = [
[
'name' => 'خوشحال',
'emoji' => '😊',
'description' => 'احساس شادی و رضایت از شرایط زندگی یا لحظه حال.'
],
[
'name' => 'غمگین',
'emoji' => '😢',
'description' => 'حس ناراحتی و اندوه که ممکن است به دلیل اتفاقی ناخوشایند باشد.'
],
[
'name' => 'آرام',
'emoji' => '😌',
'description' => 'احساسی از آرامش و رهایی از استرس و تنش.'
],
[
'name' => 'عصبانی',
'emoji' => '😠',
'description' => 'حس خشم یا ناراحتی شدید نسبت به موقعیتی خاص.'
],
[
'name' => 'هیجان‌زده',
'emoji' => '🤩',
'description' => 'احساس شور و شوق فراوان برای تجربه یا رویدادی خاص.'
],
[
'name' => 'خسته',
'emoji' => '😴',
'description' => 'کمبود انرژی و نیاز به استراحت یا خواب.'
]
];
foreach ($moods as $mood) {
Mood::create($mood);
}
}
}