add code to control unit
This commit is contained in:
@@ -50,6 +50,7 @@ class RequestPortalController extends Controller
|
|||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => json_encode($request->area),
|
||||||
|
'code' => rand(100000, 999999)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$mission->rahdaran()->attach($request->rahdaran);
|
$mission->rahdaran()->attach($request->rahdaran);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Http\Requests\V3\Mission\TransportaionUnit\AllocateRequest;
|
use App\Http\Requests\V3\Mission\TransportaionUnit\AllocateRequest;
|
||||||
use App\Http\Requests\V3\Mission\TransportaionUnit\DeallocateRequest;
|
use App\Http\Requests\V3\Mission\TransportaionUnit\DeallocateRequest;
|
||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\CMMSMachine;
|
||||||
use App\Models\Mission;
|
use App\Models\Mission;
|
||||||
use App\Services\Cartables\Mission\TransportationUnitService;
|
use App\Services\Cartables\Mission\TransportationUnitService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -65,8 +66,12 @@ class TransportationUnitController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rahdaran(Mission $mission): JsonResponse
|
public function machinesList(Mission $mission): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->successResponse($mission->rahdaran()->get(['rahdaran.id', 'rahdaran.name', 'rahdaran.code']));
|
return $this->successResponse(
|
||||||
|
CMMSMachine::query()
|
||||||
|
->where('car_type', '=', $mission->car_type)
|
||||||
|
->get(['machine_code', 'id', 'plak_number', 'car_name'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class StartRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return $this->mission->state_id == MissionStates::PENDING_CONFIRMATION->value;
|
return ($this->mission->state_id == MissionStates::PENDING_CONFIRMATION->value && $this->mission->code == $this->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +24,7 @@ class StartRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//
|
'code' => 'required|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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->string('car_type')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cmms_machines', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('car_type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -467,6 +467,7 @@ Route::prefix('missions')
|
|||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::post('/allocate/{mission}', 'allocate')->name('allocate');
|
Route::post('/allocate/{mission}', 'allocate')->name('allocate');
|
||||||
Route::post('/deallocate/{mission}', 'deallocate')->name('deallocate');
|
Route::post('/deallocate/{mission}', 'deallocate')->name('deallocate');
|
||||||
|
Route::post('/machines_list/{mission}', 'machinesList')->name('machinesList');
|
||||||
});
|
});
|
||||||
Route::name('controlUnit.')
|
Route::name('controlUnit.')
|
||||||
->prefix('control_unit')
|
->prefix('control_unit')
|
||||||
|
|||||||
Reference in New Issue
Block a user