add new columns to road patrol
This commit is contained in:
@@ -145,7 +145,7 @@ class RoadPatrolProjectController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function store(StoreRequest $request, NominatimService $nominatimService)
|
||||
public function store(StoreRequest $request, NominatimService $nominatimService): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -195,6 +195,9 @@ class RoadPatrolProjectController extends Controller
|
||||
'start_time' => $request->start_time,
|
||||
'end_time' => $request->end_time,
|
||||
'description' => $request->description ?? null,
|
||||
'fuel_consumption' => $request->fuel_consumption,
|
||||
'vehicle_runtime' => $request->vehicle_runtime,
|
||||
'stop_points' => json_encode($request->stop_points),
|
||||
]);
|
||||
|
||||
$road_patrol->rahdaran()->attach($request->road_patrol_rahdaran_id);
|
||||
|
||||
@@ -30,6 +30,13 @@ class StoreRequest extends FormRequest
|
||||
'officer_phone_number' => 'required|digits:11',
|
||||
'start_time' => 'required|date_format:Y-m-d H:i',
|
||||
'end_time' => 'required|date_format:Y-m-d H:i|after:start_time',
|
||||
'fuel_consumption' => 'required|integer',
|
||||
'vehicle_runtime' => 'required|integer',
|
||||
'stop_points' => 'required|array',
|
||||
'road_patrol_machines_id' => 'required|array',
|
||||
'road_patrol_machines_id.*' => 'required|exists:cmms_machines,id',
|
||||
'road_patrol_rahdaran_id' => 'required|array',
|
||||
'road_patrol_rahdaran_id.*' => 'required|exists:rahdaran,id',
|
||||
|
||||
'observed_items' => 'array',
|
||||
'observed_items.*.item_id' => 'required|integer',
|
||||
@@ -47,10 +54,6 @@ class StoreRequest extends FormRequest
|
||||
'observed_items.*.priority' => 'integer|in:1,2,3|required_if:observed_items.*.instant_action,0',
|
||||
'observed_items.*.priority_fa' => 'string|required_if:observed_items.*.instant_action,0',
|
||||
'description' => 'string|required_with:observed_items',
|
||||
'road_patrol_machines_id' => 'required|array',
|
||||
'road_patrol_machines_id.*' => 'required|exists:cmms_machines,id',
|
||||
'road_patrol_rahdaran_id' => 'required|array',
|
||||
'road_patrol_rahdaran_id.*' => 'required|exists:rahdaran,id',
|
||||
|
||||
'observed_items.*.road_item_machines_id' => 'required_if:observed_items.*.instant_action,1|array',
|
||||
'observed_items.*.road_item_machines_id.*' => 'required_if:observed_items.*.instant_action,1|exists:cmms_machines,id',
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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('road_patrols', function (Blueprint $table) {
|
||||
$table->decimal('start_lat', 12, 10)->nullable()->change();
|
||||
$table->decimal('start_lng', 12, 10)->nullable()->change();
|
||||
$table->decimal('end_lat', 12, 10)->nullable()->change();
|
||||
$table->decimal('end_lng', 12, 10)->nullable()->change();
|
||||
$table->integer('fuel_consumption')->nullable();
|
||||
$table->integer('vehicle_runtime')->nullable();
|
||||
$table->json('stop_points')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('road_patrols', function (Blueprint $table) {
|
||||
$table->decimal('start_lat', 12, 10)->change();
|
||||
$table->decimal('start_lng', 12, 10)->change();
|
||||
$table->decimal('end_lat', 12, 10)->change();
|
||||
$table->decimal('end_lng', 12, 10)->change();
|
||||
$table->dropColumn('fuel_consumption');
|
||||
$table->dropColumn('vehicle_runtime');
|
||||
$table->dropColumn('stop_points');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user