remove mission relation from cartables

This commit is contained in:
2025-09-14 08:56:21 +03:30
parent 20b2cb01d7
commit c86b001ff6
12 changed files with 41 additions and 31 deletions

View File

@@ -314,6 +314,8 @@ class AccidentReceiptController extends Controller
$response = json_decode($paymentService->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
throw_if(!$response->isPayed, new ProhibitedAction('پرداخت انجام نشده است'));
if ($response->isPayed) {
$accident->update([
'status' => AccidentStates::PARDAKHT_FACTOR->value,

View File

@@ -12,6 +12,7 @@ use App\Http\Traits\ApiResponse;
use App\Models\City;
use App\Models\Harim;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\DB;
class PanjareVahedController extends Controller
{
@@ -19,11 +20,15 @@ class PanjareVahedController extends Controller
public function receiveNewRequest(ReceiveNewRequest $request)
{
$wkt = 'POLYGON((' . implode(',', array_map(fn($c) => "{$c[0]} {$c[1]}", $request->primary_area['coordinates'])) . '))';
$result = DB::selectOne("SELECT ST_AsText(ST_PointOnSurface(ST_GeomFromText(?, 4326))) AS point", [$wkt]);
preg_match('/POINT\(([^ ]+) ([^ ]+)\)/', $result->point, $matches);
try {
$city = City::query()
->whereRaw("ST_Contains(
geometry,
ST_SRID(ST_GeomFromText('POINT($request->lng $request->lat)'), 4326))"
ST_GeomFromText('POINT($matches[2] $matches[1])', 4326))"
)
->firstOrFail(['id', 'name_fa', 'province_id']);
}
@@ -31,8 +36,7 @@ class PanjareVahedController extends Controller
$city = City::query()
->orderByRaw("ST_Distance(
geometry,
ST_SRID(ST_GeomFromText('POINT($request->lng $request->lat)'), 4326)
) ASC"
ST_GeomFromText('POINT($matches[2] $matches[1])', 4326)) ASC"
)
->first(['id', 'name_fa', 'province_id']);
}
@@ -42,7 +46,7 @@ class PanjareVahedController extends Controller
Harim::query()->create([
'state_id' => $state,
'state_name' => HarimStates::name($state),
'panjare_vahed_id' => $request->panjare_vahed_id,
'panjare_vahed_id' => $request->request_id,
'national_id' => $request->national_id,
'phone_number' => $request->phone_number,
'request_date' => $request->request_date,
@@ -58,8 +62,6 @@ class PanjareVahedController extends Controller
'response_options' => json_encode($request->response_options),
'isic' => $request->isic,
'primary_area' => json_encode($request->primary_area),
'lat' => $request->lat,
'lng' => $request->lng,
]);
return $this->successResponse([
@@ -73,11 +75,11 @@ class PanjareVahedController extends Controller
$state = HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value;
Harim::query()
->firstWhere('panjare_vahed_id', '=', $request->panjare_vahed_id)
->firstWhere('panjare_vahed_id', '=', $request->request_id)
->update([
'state_id' => $state,
'state_name' => HarimStates::name($state),
'access_road' => $request->access_road,
'access_road' => json_encode($request->access_road),
]);
return $this->successResponse();
@@ -89,7 +91,7 @@ class PanjareVahedController extends Controller
$state = HarimStates::MOKHALEFAT_BA_DASTGAH->value;
Harim::query()
->firstWhere('panjare_vahed_id', '=', $request->panjare_vahed_id)
->firstWhere('panjare_vahed_id', '=', $request->request_id)
->update([
'state_id' => $state,
'state_name' => HarimStates::name($state),
@@ -104,12 +106,12 @@ class PanjareVahedController extends Controller
$state = HarimStates::TAEDE_ARSE_VA_AYAN_ERSAL_SHODE_TAVASOT_DAFTAR_HARIM->value;
Harim::query()
->firstWhere('panjare_vahed_id', '=', $request->panjare_vahed_id)
->firstWhere('panjare_vahed_id', '=', $request->request_id)
->update([
'state_id' => $state,
'state_name' => HarimStates::name($state),
'final_area' => $request->final_area,
'final_plan' => $request->final_plan,
'final_area' => json_encode($request->final_area),
'final_plan' => json_encode($request->final_plan),
]);
return $this->successResponse();

View File

@@ -160,6 +160,11 @@ class RequestPortalController extends Controller
$mission->rahdaran()->sync($request->rahdaran);
$mission->machines()->attach($request->machines);
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
if ($mission->category_id == 2) {
$rpc = new OperatorController();
$rpc->store($mission);
}
});
return $this->successResponse();