From afb94681de666b4b4b12560b6653047e6ee337bb Mon Sep 17 00:00:00 2001 From: faezehzafarbakhsh Date: Sun, 19 Oct 2025 16:54:39 +0330 Subject: [PATCH] create new culumn in machine and add in controller and createe enum for this --- app/Enums/MachineStates.php | 19 +++++++++++++ .../Controllers/V3/CMMSMachinesController.php | 6 ++-- ...2736_add_status_to_cmms_machines_table.php | 28 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 app/Enums/MachineStates.php create mode 100644 database/migrations/2025_10_19_152736_add_status_to_cmms_machines_table.php diff --git a/app/Enums/MachineStates.php b/app/Enums/MachineStates.php new file mode 100644 index 00000000..ccdd6e2e --- /dev/null +++ b/app/Enums/MachineStates.php @@ -0,0 +1,19 @@ + 'اماده به کار', + self::REZERV => 'رزرو', + self::DAR_HAL_MAMOREAT => 'در حال ماموریت', + }; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/V3/CMMSMachinesController.php b/app/Http/Controllers/V3/CMMSMachinesController.php index b74be799..d0819a1a 100644 --- a/app/Http/Controllers/V3/CMMSMachinesController.php +++ b/app/Http/Controllers/V3/CMMSMachinesController.php @@ -22,13 +22,13 @@ class CMMSMachinesController extends Controller $request, allowedFilters: ['*'], allowedSortings: ['*'], - allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type'] + allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status'], )); } public function list(): JsonResponse { - $machinesList = CMMSMachine::query()->get(['machine_code', 'id', 'plak_number', 'car_name', 'car_type']); + $machinesList = CMMSMachine::query()->get(['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status']); return $this->successResponse($machinesList); } @@ -37,7 +37,7 @@ class CMMSMachinesController extends Controller { $matchedSearchedMachines = CMMSMachine::query() ->where('machine_code', 'LIKE', "%{$request->machine_code}%") - ->get(['machine_code', 'id', 'plak_number', 'car_name']); + ->get(['machine_code', 'id', 'plak_number', 'car_name', 'status']); return $this->successResponse($matchedSearchedMachines); } diff --git a/database/migrations/2025_10_19_152736_add_status_to_cmms_machines_table.php b/database/migrations/2025_10_19_152736_add_status_to_cmms_machines_table.php new file mode 100644 index 00000000..60dbf9f3 --- /dev/null +++ b/database/migrations/2025_10_19_152736_add_status_to_cmms_machines_table.php @@ -0,0 +1,28 @@ +integer('status')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('cmms_machines', function (Blueprint $table) { + $table->dropColumn('status'); + }); + } +};