Merge pull request #74 from witelgroup/feature/NewCloumnMachines
create new culumn in machine and add in controller and createe enum f…
This commit is contained in:
19
app/Enums/MachineStates.php
Normal file
19
app/Enums/MachineStates.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum MachineStates: int
|
||||||
|
{
|
||||||
|
case AMADE_BE_CAR = 1;
|
||||||
|
case REZERV = 2;
|
||||||
|
case DAR_HAL_MAMOREAT = 3;
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::AMADE_BE_CAR => 'اماده به کار',
|
||||||
|
self::REZERV => 'رزرو',
|
||||||
|
self::DAR_HAL_MAMOREAT => 'در حال ماموریت',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,13 +22,13 @@ class CMMSMachinesController extends Controller
|
|||||||
$request,
|
$request,
|
||||||
allowedFilters: ['*'],
|
allowedFilters: ['*'],
|
||||||
allowedSortings: ['*'],
|
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
|
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);
|
return $this->successResponse($machinesList);
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ class CMMSMachinesController extends Controller
|
|||||||
{
|
{
|
||||||
$matchedSearchedMachines = CMMSMachine::query()
|
$matchedSearchedMachines = CMMSMachine::query()
|
||||||
->where('machine_code', 'LIKE', "%{$request->machine_code}%")
|
->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);
|
return $this->successResponse($matchedSearchedMachines);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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::table('cmms_machines', function (Blueprint $table) {
|
||||||
|
$table->integer('status')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cmms_machines', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user