create all azmayesh resources and its dependencies

This commit is contained in:
2024-10-22 16:40:36 +03:30
parent 9aa3cf320f
commit c2ceb3d343
20 changed files with 548 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Azmayesh>
*/
class AzmayeshFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AzmayeshField>
*/
class AzmayeshFieldFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AzmayeshSample>
*/
class AzmayeshSampleFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AzmayeshType>
*/
class AzmayeshTypeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

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::create('azmayesh_fields', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('unit');
$table->string('type');
$table->string('option')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('azmayesh_fields');
}
};

View File

@@ -0,0 +1,28 @@
<?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('azmayesh_types', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('azmayesh_types');
}
};

View File

@@ -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(): void
{
Schema::create('azmayeshes', function (Blueprint $table) {
$table->id();
$table->foreignId('azmayesh_type_id')->constrained('azmayesh_types');
$table->string('azmayesh_type_name');
$table->string('lat');
$table->string('lng');
$table->foreignId('province_id')->constrained('provinces');
$table->string('province_name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('azmayeshes');
}
};

View File

@@ -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('azmayesh_samples', function (Blueprint $table) {
$table->id();
$table->foreignId('azmayesh_id')->constrained('azmayeshes');
$table->string('azmayesh_name');
$table->json('data');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('azmayesh_samples');
}
};

View File

@@ -0,0 +1,29 @@
<?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('azmayesh_field_azmayesh_type', function (Blueprint $table) {
$table->id();
$table->foreignId('azmayesh_field_id')->constrained('azmayesh_fields');
$table->foreignId('azmayesh_type_id')->constrained('azmayesh_types');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('azmayesh_field_azmayesh_type');
}
};

View File

@@ -0,0 +1,37 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AzmayeshFieldSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('azmayesh_fields')->insert([
[
'id' => 1,
'name' => 'طول',
'unit' => 'سانتی متر',
'type' => 'input',
'option' => null,
'created_at' => now(),
'updated_at' => now()
],
[
'id' => 2,
'name' => 'عرض',
'unit' => 'سانتی متر',
'type' => 'input',
'option' => null,
'created_at' => now(),
'updated_at' => now()
],
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Seeders;
use App\Models\Azmayesh;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AzmayeshSampleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('azmayesh_samples')->insert([
[
'id' => 1,
'azmayesh_id' => Azmayesh::factory(),
'azmayesh_name' => function (array $attributes) {
return Azmayesh::query()->find($attributes['azmayesh_id'])->name;
},
'data' => json_encode([
1 => 'test'
]),
'created_at' => now(),
'updated_at' => now()
],
]);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AzmayeshSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('azmayeshes')->insert([
[
'id' => 1,
'name' => '',
'created_at' => now(),
'updated_at' => now()
],
[
'id' => 2,
'name' => '',
'created_at' => now(),
'updated_at' => now()
],
]);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AzmayeshTypeSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('azmayesh_types')->insert([
[
'id' => 1,
'name' => 'تعیین مقاومت فشاری بتن',
'created_at' => now(),
'updated_at' => now()
],
]);
}
}