diff --git a/app/Http/Controllers/V3/Azmayesh/AzmayeshController.php b/app/Http/Controllers/V3/Azmayesh/AzmayeshController.php new file mode 100644 index 00000000..a4e2a3a0 --- /dev/null +++ b/app/Http/Controllers/V3/Azmayesh/AzmayeshController.php @@ -0,0 +1,69 @@ +successResponse($data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(Azmayesh $azmayesh): JsonResponse + { + return $this->successResponse($azmayesh->load('azmayeshSamples')); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, Azmayesh $azmayesh) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Azmayesh $azmayesh): JsonResponse + { + $azmayesh->delete(); + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/V3/Azmayesh/AzmayeshTypeController.php b/app/Http/Controllers/V3/Azmayesh/AzmayeshTypeController.php new file mode 100644 index 00000000..d3dbe072 --- /dev/null +++ b/app/Http/Controllers/V3/Azmayesh/AzmayeshTypeController.php @@ -0,0 +1,28 @@ +successResponse($allTypes); + } + + public function fields(AzmayeshType $azmayeshType): JsonResponse + { + $fields = $azmayeshType->azmayeshFields(); + + return $this->successResponse($fields); + } +} diff --git a/app/Models/Azmayesh.php b/app/Models/Azmayesh.php new file mode 100644 index 00000000..a790c42c --- /dev/null +++ b/app/Models/Azmayesh.php @@ -0,0 +1,19 @@ +hasMany(AzmayeshSample::class); + } +} diff --git a/app/Models/AzmayeshField.php b/app/Models/AzmayeshField.php new file mode 100644 index 00000000..d6bd90a2 --- /dev/null +++ b/app/Models/AzmayeshField.php @@ -0,0 +1,19 @@ +belongsToMany(AzmayeshType::class); + } +} diff --git a/app/Models/AzmayeshSample.php b/app/Models/AzmayeshSample.php new file mode 100644 index 00000000..baa62a61 --- /dev/null +++ b/app/Models/AzmayeshSample.php @@ -0,0 +1,11 @@ +hasMany(Azmayesh::class); + } + + public function azmayeshFields(): BelongsToMany + { + return $this->belongsToMany(AzmayeshField::class); + } +} diff --git a/database/factories/AzmayeshFactory.php b/database/factories/AzmayeshFactory.php new file mode 100644 index 00000000..8b388147 --- /dev/null +++ b/database/factories/AzmayeshFactory.php @@ -0,0 +1,23 @@ + + */ +class AzmayeshFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/AzmayeshFieldFactory.php b/database/factories/AzmayeshFieldFactory.php new file mode 100644 index 00000000..01716b78 --- /dev/null +++ b/database/factories/AzmayeshFieldFactory.php @@ -0,0 +1,23 @@ + + */ +class AzmayeshFieldFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/AzmayeshSampleFactory.php b/database/factories/AzmayeshSampleFactory.php new file mode 100644 index 00000000..73670225 --- /dev/null +++ b/database/factories/AzmayeshSampleFactory.php @@ -0,0 +1,23 @@ + + */ +class AzmayeshSampleFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/AzmayeshTypeFactory.php b/database/factories/AzmayeshTypeFactory.php new file mode 100644 index 00000000..3a2bb0a2 --- /dev/null +++ b/database/factories/AzmayeshTypeFactory.php @@ -0,0 +1,23 @@ + + */ +class AzmayeshTypeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2024_10_22_092756_create_azmayesh_fields_table.php b/database/migrations/2024_10_22_092756_create_azmayesh_fields_table.php new file mode 100644 index 00000000..b68d79c7 --- /dev/null +++ b/database/migrations/2024_10_22_092756_create_azmayesh_fields_table.php @@ -0,0 +1,31 @@ +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'); + } +}; diff --git a/database/migrations/2024_10_22_092762_create_azmayesh_types_table.php b/database/migrations/2024_10_22_092762_create_azmayesh_types_table.php new file mode 100644 index 00000000..db0e636c --- /dev/null +++ b/database/migrations/2024_10_22_092762_create_azmayesh_types_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('azmayesh_types'); + } +}; diff --git a/database/migrations/2024_10_22_092800_create_azmayeshes_table.php b/database/migrations/2024_10_22_092800_create_azmayeshes_table.php new file mode 100644 index 00000000..e36d00cb --- /dev/null +++ b/database/migrations/2024_10_22_092800_create_azmayeshes_table.php @@ -0,0 +1,33 @@ +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'); + } +}; diff --git a/database/migrations/2024_10_22_114035_create_azmayesh_samples_table.php b/database/migrations/2024_10_22_114035_create_azmayesh_samples_table.php new file mode 100644 index 00000000..a4e61680 --- /dev/null +++ b/database/migrations/2024_10_22_114035_create_azmayesh_samples_table.php @@ -0,0 +1,30 @@ +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'); + } +}; diff --git a/database/migrations/2024_10_22_152052_create_azmayesh_field_azmayesh_type_table.php b/database/migrations/2024_10_22_152052_create_azmayesh_field_azmayesh_type_table.php new file mode 100644 index 00000000..5507811c --- /dev/null +++ b/database/migrations/2024_10_22_152052_create_azmayesh_field_azmayesh_type_table.php @@ -0,0 +1,29 @@ +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'); + } +}; diff --git a/database/seeders/AzmayeshFieldSeeder.php b/database/seeders/AzmayeshFieldSeeder.php new file mode 100644 index 00000000..a4201fa3 --- /dev/null +++ b/database/seeders/AzmayeshFieldSeeder.php @@ -0,0 +1,37 @@ +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() + ], + ]); + } +} diff --git a/database/seeders/AzmayeshSampleSeeder.php b/database/seeders/AzmayeshSampleSeeder.php new file mode 100644 index 00000000..66a53b02 --- /dev/null +++ b/database/seeders/AzmayeshSampleSeeder.php @@ -0,0 +1,32 @@ +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() + ], + ]); + } +} diff --git a/database/seeders/AzmayeshSeeder.php b/database/seeders/AzmayeshSeeder.php new file mode 100644 index 00000000..b0051ad9 --- /dev/null +++ b/database/seeders/AzmayeshSeeder.php @@ -0,0 +1,31 @@ +insert([ + [ + 'id' => 1, + 'name' => '', + 'created_at' => now(), + 'updated_at' => now() + ], + [ + 'id' => 2, + 'name' => '', + 'created_at' => now(), + 'updated_at' => now() + ], + ]); + } +} diff --git a/database/seeders/AzmayeshTypeSeeder.php b/database/seeders/AzmayeshTypeSeeder.php new file mode 100644 index 00000000..3d3f56e3 --- /dev/null +++ b/database/seeders/AzmayeshTypeSeeder.php @@ -0,0 +1,25 @@ +insert([ + [ + 'id' => 1, + 'name' => 'تعیین مقاومت فشاری بتن', + 'created_at' => now(), + 'updated_at' => now() + ], + ]); + } +} diff --git a/routes/v3.php b/routes/v3.php index 9597fc93..193d6b0f 100644 --- a/routes/v3.php +++ b/routes/v3.php @@ -1,5 +1,6 @@ name('edit'); Route::post('change_password', 'changePassword')->name('changePassword'); }); + +Route::prefix('azmayesh') + ->name('azmayesh.') + ->controller(AzmayeshController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::get('/fields', 'fields')->name('fields'); + });