Merge branch 'feature/AzmayeshTypePanel' into 'develop'

Feature/azmayesh type panel

See merge request witelgroup/rms_v2!31
This commit is contained in:
2024-11-17 11:41:09 +00:00
19 changed files with 754 additions and 14 deletions

View File

@@ -59,7 +59,7 @@ class AzmayeshSampleController extends Controller
/**
* Display the specified resource.
*/
public function show(AzmayeshSample $azmayeshSample)
public function show(AzmayeshSample $azmayeshSample): JsonResponse
{
return $this->successResponse($azmayeshSample);
}
@@ -67,7 +67,7 @@ class AzmayeshSampleController extends Controller
/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, AzmayeshSample $azmayeshSample)
public function update(UpdateRequest $request, AzmayeshSample $azmayeshSample): JsonResponse
{
$azmayesh = Azmayesh::query()->findOrFail($request->azmayesh_id);
@@ -83,7 +83,7 @@ class AzmayeshSampleController extends Controller
/**
* Remove the specified resource from storage.
*/
public function destroy(AzmayeshSample $azmayeshSample)
public function destroy(AzmayeshSample $azmayeshSample): JsonResponse
{
$azmayeshSample->delete();

View File

@@ -2,17 +2,42 @@
namespace App\Http\Controllers\V3\Azmayesh;
use App\Facades\DataTable\DataTableFacade;
use App\Http\Controllers\Controller;
use App\Http\Requests\V3\AzmayeshType\StoreRequest;
use App\Http\Requests\V3\AzmayeshType\UpdateRequest;
use App\Http\Traits\ApiResponse;
use App\Models\AzmayeshField;
use App\Models\AzmayeshType;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class AzmayeshTypeController extends Controller
{
use ApiResponse;
public function index(): JsonResponse
public function index(Request $request): JsonResponse
{
$columns = array(
'id', 'name'
);
$allowedFilters = $columns;
$allowedSortings = $columns;
$query = AzmayeshType::query();
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: $allowedFilters,
allowedSortings: $allowedSortings);
return response()->json($data);
}
public function list(): JsonResponse
{
$allTypes = AzmayeshType::all();
@@ -21,8 +46,71 @@ class AzmayeshTypeController extends Controller
public function fields(AzmayeshType $azmayeshType): JsonResponse
{
$fields = $azmayeshType->azmayeshFields->select('id', 'name', 'unit', 'type', 'option');
return $this->successResponse($azmayeshType->azmayeshFields);
}
return $this->successResponse($fields);
public function store(StoreRequest $request): JsonResponse
{
DB::transaction(function () use ($request)
{
$azmayeshType = AzmayeshType::query()->create([
'name' => $request->name
]);
$fieldsID = [];
foreach ($request->fields as $field)
{
$azmayeshField = AzmayeshField::query()->firstOrCreate($field, $field);
$fieldsID[] = $azmayeshField->id;
}
$azmayeshType->azmayeshFields()->attach($fieldsID);
});
return $this->successResponse();
}
/**
* Display the specified resource.
*/
public function show(AzmayeshType $azmayeshType): JsonResponse
{
return $this->successResponse($azmayeshType->load(['azmayeshFields']));
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, AzmayeshType $azmayeshType): JsonResponse
{
DB::transaction(function () use ($request, $azmayeshType)
{
$azmayeshType->update([
'name' => $request->name
]);
$fieldsID = [];
foreach ($request->fields as $field)
{
$azmayeshField = AzmayeshField::query()->updateOrCreate($field, $field);
$fieldsID[] = $azmayeshField->id;
}
$azmayeshType->azmayeshFields()->sync($fieldsID);
});
return $this->successResponse();
}
/**
* Remove the specified resource from storage.
*/
public function destroy(AzmayeshType $azmayeshType): JsonResponse
{
$azmayeshType->delete();
return $this->successResponse();
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\V3\AzmayeshType;
use Illuminate\Foundation\Http\FormRequest;
class StoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|string',
'fields' => 'required|array',
'fields.*.name' => 'required|string',
'fields.*.unit' => 'string',
'fields.*.type' => 'required|string',
'fields.*.option' => 'string',
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\V3\AzmayeshType;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|string',
'fields' => 'required|array',
'fields.*.name' => 'required|string',
'fields.*.unit' => 'string',
'fields.*.type' => 'required|string',
'fields.*.option' => 'string',
];
}
}

View File

@@ -12,6 +12,7 @@ class AzmayeshField extends Model
use HasFactory;
protected $guarded = [];
protected $hidden = ['pivot'];
protected function option(): Attribute
{

View File

@@ -12,6 +12,7 @@ class AzmayeshType extends Model
use HasFactory;
protected $guarded = [];
protected $hidden = ['pivot'];
public function azmayeshes(): HasMany
{

View File

@@ -13,8 +13,8 @@ return new class extends Migration
{
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->foreignId('azmayesh_field_id')->constrained('azmayesh_fields')->cascadeOnDelete();
$table->foreignId('azmayesh_type_id')->constrained('azmayesh_types')->cascadeOnDelete();
$table->timestamps();
});
}

View File

@@ -194,6 +194,11 @@ return [
'applicant' => 'متقاضی',
'province_id' => 'استان',
'azmayesh_id' => 'آزمایش',
'data' => 'داده'
'data' => 'داده',
'fields' => 'فیلد ها',
'fields.*.name' => 'نام فیلد',
'fields.*.unit' => 'واحد فیلد',
'fields.*.type' => 'نوع فیلد',
'fields.*.option' => 'گزینه های فیلد',
],
];

View File

@@ -41,7 +41,12 @@ Route::prefix('azmayesh_types')
->controller(AzmayeshTypeController::class)
->group(function () {
Route::get('/', 'index')->name('index');
Route::get('/list', 'list')->name('list');
Route::get('/fields/{azmayeshType}', 'fields')->name('fields');
Route::get('/{azmayeshType}', 'show')->name('show');
Route::post('/store', 'store')->name('store');
Route::post('/update/{azmayeshType}', 'update')->name('update');
Route::post('/delete/{azmayeshType}', 'destroy')->name('delete');
});
Route::prefix('azmayesh_samples')

View File

@@ -519,3 +519,4 @@ INSERT INTO edarate_shahri (name_fa,province_id,created_at,updated_at) VALUES
INSERT INTO edarate_shahri (name_fa,province_id,created_at,updated_at) VALUES
('اداره خمام',28,'2023-06-17 08:43:14','2023-06-17 08:43:14'),
('اداره اصلاندوز',3,'2023-08-15 09:33:55','2023-08-15 09:33:55');
('اداره گالیکش',27,'2024-11-16 14:33:55','2024-11-16 14:33:55');

View File

@@ -3,6 +3,7 @@
namespace Tests\Feature\V3\AzmayeshSample;
use App\Models\Azmayesh;
use App\Models\AzmayeshSample;
use App\Models\AzmayeshType;
use App\Models\Province;
use App\Models\User;
@@ -73,7 +74,9 @@ class StoreTest extends TestCase
$this->assertDatabaseHas('azmayesh_samples', [
'azmayesh_id' => $data['azmayesh_id'],
'data' => $data['data'],
// 'data' => $data['data'],
]);
$this->assertEquals(AzmayeshSample::first()->data, $data['data']);
}
}

View File

@@ -76,7 +76,9 @@ class UpdateTest extends TestCase
$this->assertDatabaseHas('azmayesh_samples', [
'azmayesh_id' => $data['azmayesh_id'],
'data' => $data['data'],
// 'data' => $data['data'],
]);
$this->assertEquals(AzmayeshSample::first()->data, $data['data']);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Tests\Feature\V3\AzmayeshType;
use App\Models\AzmayeshField;
use App\Models\AzmayeshType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class DeleteTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*/
public function test_user_can_delete_azmayesh_type(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$azmayeshField = AzmayeshField::factory()->create();
$azmayeshType->azmayeshFields()->attach([$azmayeshField->id]);
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.delete', [$azmayeshType->id]));
$response->assertOk()
->assertExactJson([
'message' => __('messages.successful')
]);
$this->assertDatabaseMissing('azmayesh_types', [
'name' => $azmayeshType->name,
]);
$this->assertDatabaseMissing('azmayesh_field_azmayesh_type', [
'azmayesh_type_id' => $azmayeshType->id,
'azmayesh_field_id' => $azmayeshField->id,
]);
}
}

View File

@@ -24,25 +24,28 @@ class FieldsTest extends TestCase
'name' => $this->faker->name,
'unit' => $this->faker->name,
'type' => $this->faker->name,
'option' => json_encode([$this->faker->name]),
],
[
'id' => 2,
'name' => $this->faker->name,
'unit' => $this->faker->name,
'type' => $this->faker->name,
'option' => json_encode([$this->faker->name]),
],
[
'id' => 3,
'name' => $this->faker->name,
'unit' => $this->faker->name,
'type' => $this->faker->name,
'option' => json_encode([$this->faker->name]),
],
)
->create();
$azmayeshType = AzmayeshType::factory()->create();
$azmayeshType->azmayeshFields()->attach(1);
$azmayeshType->azmayeshFields()->attach([1, 2, 3]);
$user = User::factory()->create();
@@ -56,7 +59,9 @@ class FieldsTest extends TestCase
'name',
'unit',
'type',
'option'
'option',
"created_at",
"updated_at"
],
]
]);

View File

@@ -20,13 +20,19 @@ class IndexTest extends TestCase
$user = User::factory()->create();
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.index'));
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.index', [
'start' => 0,
'size' => 10,
'filters' => json_encode([]),
'sorting' => json_encode([]),
]));
$response->assertOk();
$response->assertJsonStructure([
'data' => [
'*' => [
'id',
'name',
],
]

View File

@@ -0,0 +1,35 @@
<?php
namespace Tests\Feature\V3\AzmayeshType;
use App\Models\AzmayeshType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ListTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*/
public function test_azmayesh_type_list_returned_successfully(): void
{
AzmayeshType::factory(5)->create();
$user = User::factory()->create();
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.list'));
$response->assertOk();
$response->assertJsonStructure([
'data' => [
'*' => [
'name',
],
]
]);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Tests\Feature\V3\AzmayeshType;
use App\Models\AzmayeshField;
use App\Models\AzmayeshType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ShowTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*/
public function test_azmayesh_type_details_returned_successfully(): void
{
$azmayeshType = AzmayeshType::factory()->create();
$azmayeshField = AzmayeshField::factory()->create();
$azmayeshType->azmayeshFields()->attach([$azmayeshField->id]);
$user = User::factory()->create();
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.show', [$azmayeshType->id]));
$response->assertOk();
$response->assertExactJson([
'data' => [
"id" => $azmayeshType->id,
"name" => $azmayeshType->name,
"created_at" => $azmayeshType->created_at,
"updated_at" => $azmayeshType->updated_at,
"azmayesh_fields" => [
[
"id" => $azmayeshField->id,
"name" => $azmayeshField->name,
"unit" => $azmayeshField->unit,
"type" => $azmayeshField->type,
"option" => $azmayeshField->option,
"created_at" => $azmayeshField->created_at,
"updated_at" => $azmayeshField->updated_at,
]
]
]
]);
}
}

View File

@@ -0,0 +1,208 @@
<?php
namespace Tests\Feature\V3\AzmayeshType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class StoreTest extends TestCase
{
use RefreshDatabase, WithFaker;
/**
* A basic feature test example.
*/
public function test_name_attribute_is_required(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'));
$response->assertUnprocessable()
->assertInvalid([
'name' => __('validation.required', ['attribute' => "نام"])
]);
}
public function test_name_attribute_should_be_string(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'name' => $this->faker->numberBetween(1, 10)
]);
$response->assertUnprocessable()
->assertInvalid([
'name' => __('validation.string', ['attribute' => "نام"])
]);
}
public function test_fields_attribute_is_required(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'));
$response->assertUnprocessable()
->assertInvalid([
'fields' => __('validation.required', ['attribute' => 'فیلد ها'])
]);
}
public function test_fields_attribute_should_be_array(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => $this->faker->numberBetween(1, 10)
]);
$response->assertUnprocessable()
->assertInvalid([
'fields' => __('validation.array', ['attribute' => 'فیلد ها'])
]);
}
public function test_field_name_is_required(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
[]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.name' => __('validation.required', ['attribute' => 'نام فیلد'])
]);
}
public function test_field_name_should_be_string(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
['name' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.name' => __('validation.string', ['attribute' => 'نام فیلد'])
]);
}
public function test_field_unit_should_be_string(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
['unit' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.unit' => __('validation.string', ['attribute' => 'واحد فیلد'])
]);
}
public function test_field_type_is_required(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
[]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.type' => __('validation.required', ['attribute' => 'نوع فیلد'])
]);
}
public function test_field_type_should_be_string(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
['type' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.type' => __('validation.string', ['attribute' => 'نوع فیلد'])
]);
}
public function test_field_option_should_be_string(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
'fields' => [
['option' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.option' => __('validation.string', ['attribute' => 'گزینه های فیلد'])
]);
}
public function test_user_can_store_fields_for_an_azmayesh_type(): void
{
$user = User::factory()->create();
$data = [
'name' => $this->faker->name,
'fields' => [
[
'name' => $this->faker->name,
'type' => $this->faker->randomElement(['input', 'select', 'date']),
'unit' => $this->faker->name,
'option' => json_encode(['test']),
],
[
'name' => $this->faker->name,
'type' => $this->faker->randomElement(['input', 'select', 'date']),
'unit' => $this->faker->name,
],
]
];
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), $data);
$response->assertOk()
->assertExactJson([
'message' => __('messages.successful')
]);
$this->assertDatabaseHas('azmayesh_fields', [
'name' => $data['fields'][0]['name'],
'type' => $data['fields'][0]['type'],
'unit' => $data['fields'][0]['unit'],
]);
$this->assertDatabaseHas('azmayesh_fields', [
'name' => $data['fields'][1]['name'],
'type' => $data['fields'][1]['type'],
'unit' => $data['fields'][1]['unit'],
]);
$this->assertDatabaseHas('azmayesh_types', [
'name' => $data['name'],
]);
}
}

View File

@@ -0,0 +1,220 @@
<?php
namespace Tests\Feature\V3\AzmayeshType;
use App\Models\AzmayeshType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class UpdateTest extends TestCase
{
use RefreshDatabase, WithFaker;
/**
* A basic feature test example.
*/
public function test_name_attribute_is_required(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]));
$response->assertUnprocessable()
->assertInvalid([
'name' => __('validation.required', ['attribute' => "نام"])
]);
}
public function test_name_attribute_should_be_string(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'name' => $this->faker->numberBetween(1, 10)
]);
$response->assertUnprocessable()
->assertInvalid([
'name' => __('validation.string', ['attribute' => "نام"])
]);
}
public function test_fields_attribute_is_required(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]));
$response->assertUnprocessable()
->assertInvalid([
'fields' => __('validation.required', ['attribute' => 'فیلد ها'])
]);
}
public function test_fields_attribute_should_be_array(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => $this->faker->numberBetween(1, 10)
]);
$response->assertUnprocessable()
->assertInvalid([
'fields' => __('validation.array', ['attribute' => 'فیلد ها'])
]);
}
public function test_field_name_is_required(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
[]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.name' => __('validation.required', ['attribute' => 'نام فیلد'])
]);
}
public function test_field_name_should_be_string(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
['name' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.name' => __('validation.string', ['attribute' => 'نام فیلد'])
]);
}
public function test_field_unit_should_be_string(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
['unit' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.unit' => __('validation.string', ['attribute' => 'واحد فیلد'])
]);
}
public function test_field_type_is_required(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
[]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.type' => __('validation.required', ['attribute' => 'نوع فیلد'])
]);
}
public function test_field_type_should_be_string(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
['type' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.type' => __('validation.string', ['attribute' => 'نوع فیلد'])
]);
}
public function test_field_option_should_be_string(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
'fields' => [
['option' => $this->faker->numberBetween(1, 10)]
]
]);
$response->assertUnprocessable()
->assertInvalid([
'fields.0.option' => __('validation.string', ['attribute' => 'گزینه های فیلد'])
]);
}
public function test_user_can_update_fields_for_an_azmayesh_type(): void
{
$user = User::factory()->create();
$azmayeshType = AzmayeshType::factory()->create();
$data = [
'name' => $this->faker->name,
'fields' => [
[
'name' => $this->faker->name,
'type' => $this->faker->randomElement(['input', 'select', 'date']),
'unit' => $this->faker->name,
'option' => json_encode(['test']),
],
[
'name' => $this->faker->name,
'type' => $this->faker->randomElement(['input', 'select', 'date']),
'unit' => $this->faker->name,
],
]
];
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), $data);
$response->assertOk()
->assertExactJson([
'message' => __('messages.successful')
]);
$this->assertDatabaseHas('azmayesh_fields', [
'name' => $data['fields'][0]['name'],
'type' => $data['fields'][0]['type'],
'unit' => $data['fields'][0]['unit'],
]);
$this->assertDatabaseHas('azmayesh_fields', [
'name' => $data['fields'][1]['name'],
'type' => $data['fields'][1]['type'],
'unit' => $data['fields'][1]['unit'],
]);
$this->assertDatabaseHas('azmayesh_types', [
'name' => $data['name'],
]);
}
}