add static azmayesh fields
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
@@ -17,7 +19,14 @@ class AzmayeshFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'azmayesh_type_id' => AzmayeshType::factory(),
|
||||
'azmayesh_type_name' => function (array $attributes) {
|
||||
return AzmayeshType::query()->find($attributes['azmayesh_type_id'])->name;
|
||||
},
|
||||
'province_id' => Province::factory(),
|
||||
'province_name' => function (array $attributes) {
|
||||
return Province::query()->find($attributes['province_id'])->name;
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ class AzmayeshFieldFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'name' => $this->faker->name,
|
||||
'unit' => $this->faker->name,
|
||||
'type' => $this->faker->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Azmayesh;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,11 @@ class AzmayeshSampleFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'azmayesh_id' => Azmayesh::factory(),
|
||||
'azmayesh_name' => function (array $attributes) {
|
||||
return Azmayesh::query()->find($attributes['azmayesh_id'])->name;
|
||||
},
|
||||
'data' => json_encode(['test']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class AzmayeshTypeFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'name' => $this->faker->name
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,18 @@ return new class extends Migration
|
||||
$table->string('azmayesh_type_name');
|
||||
$table->string('lat');
|
||||
$table->string('lng');
|
||||
$table->foreignId('province_id')->constrained('provinces');
|
||||
$table->unsignedTinyInteger('province_id');
|
||||
$table->foreign('province_id')->references('id')->on('provinces');
|
||||
$table->string('province_name');
|
||||
$table->date('request_date');
|
||||
$table->date('report_date');
|
||||
$table->integer('request_number');
|
||||
$table->string('employer');
|
||||
$table->string('contractor');
|
||||
$table->integer('work_number');
|
||||
$table->string('project_name');
|
||||
$table->string('consultant');
|
||||
$table->string('applicant');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,13 +16,41 @@ class AzmayeshSeeder extends Seeder
|
||||
DB::table('azmayeshes')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '',
|
||||
'lat' => '13.45',
|
||||
'lng' => '11.85',
|
||||
'azmayesh_type_id' => 1,
|
||||
'azmayesh_type_name' => 'test',
|
||||
'province_id' => 11,
|
||||
'province_name' => 'test',
|
||||
'request_date' => '1403-07-04',
|
||||
'report_date' => '1403-07-05',
|
||||
'request_number' => 0,
|
||||
'employer' => 'test',
|
||||
'contractor' => 'test',
|
||||
'work_number' => 0,
|
||||
'project_name' => 'test',
|
||||
'consultant' => 'test',
|
||||
'applicant' => 'test',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '',
|
||||
'lat' => '13.45',
|
||||
'lng' => '11.85',
|
||||
'azmayesh_type_id' => 1,
|
||||
'azmayesh_type_name' => 'test',
|
||||
'province_id' => 11,
|
||||
'province_name' => 'test',
|
||||
'request_date' => '1403-07-04',
|
||||
'report_date' => '1403-07-05',
|
||||
'request_number' => '0',
|
||||
'employer' => 'test',
|
||||
'contractor' => 'test',
|
||||
'work_number' => '0',
|
||||
'project_name' => 'test',
|
||||
'consultant' => 'test',
|
||||
'applicant' => 'test',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user