add user id column to azmayesh table

This commit is contained in:
2024-12-02 10:37:48 +03:30
parent cc0eb78a53
commit a706406261
5 changed files with 63 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ namespace Database\Factories;
use App\Models\AzmayeshType;
use App\Models\Province;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -38,6 +39,10 @@ class AzmayeshFactory extends Factory
'project_name' => $this->faker->name,
'consultant' => $this->faker->name,
'applicant' => $this->faker->name,
'user_id' => User::factory(),
'user_name' => function (array $attributes) {
return User::query()->find($attributes['user_id'])->name;
},
];
}
}

View File

@@ -0,0 +1,31 @@
<?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::table('azmayeshes', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->string('user_name');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('azmayeshes', function (Blueprint $table) {
$table->dropColumn('user_id');
$table->dropColumn('user_name');
});
}
};

View File

@@ -31,6 +31,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'اجرای پروژه پل میرزای شیرازی شریفیه',
'consultant' => '-',
'applicant' => 'شهرداری شریفیه',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],
@@ -51,6 +53,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'کنترل کیفی پروژه های اجرایی شهرداری الوند',
'consultant' => '-',
'applicant' => 'شهرداری الوند',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],
@@ -71,6 +75,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'کنترل کیفی پروژه های روستای ولدآباد',
'consultant' => '-',
'applicant' => 'بنیاد مسکن استان قزوین',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],
@@ -91,6 +97,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'نیوجرسی مفصلی جهت ایمن سازی آزادراه های قزوین-کرج و قزوین-زنجان',
'consultant' => '-',
'applicant' => 'اداره کل راهداری و حمل و نقل جاده ای استان قزوین',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],
@@ -111,6 +119,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'احداث راه های دسترسی مجتمع خدمات رفاهی حوزه آبیک-مجتمع آقای کلانی',
'consultant' => '-',
'applicant' => 'اداره کل راهداری و حمل و نقل جاده ای استان قزوین',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],
@@ -131,6 +141,8 @@ class AzmayeshSeeder extends Seeder
'project_name' => 'آماده سازی محوطه دپوی سیلو کارخانه قند قزوین',
'consultant' => '-',
'applicant' => 'شرکت سهامی عام کارخانجات قند قزوین',
'user_id' => 470,
'user_name' => 'اداره کل ستاد',
'created_at' => now(),
'updated_at' => now()
],