Skip to content

Commit 989188e

Browse files
committed
patched place creation with address attribute, patched customer & facilitator resolution for order creation
1 parent 50d3e60 commit 989188e

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

server/src/Http/Controllers/Api/v1/OrderController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function create(CreateOrderRequest $request)
197197
'company_uuid' => session('company'),
198198
],
199199
[
200-
'with_table' => true
200+
'with_table' => true,
201201
]
202202
);
203203

@@ -222,7 +222,7 @@ public function create(CreateOrderRequest $request)
222222
'company_uuid' => session('company'),
223223
],
224224
[
225-
'with_table' => true
225+
'with_table' => true,
226226
]
227227
);
228228

@@ -461,7 +461,7 @@ public function update($id, UpdateOrderRequest $request)
461461
'company_uuid' => session('company'),
462462
],
463463
[
464-
'with_table' => true
464+
'with_table' => true,
465465
]
466466
);
467467

@@ -480,7 +480,7 @@ public function update($id, UpdateOrderRequest $request)
480480
'company_uuid' => session('company'),
481481
],
482482
[
483-
'with_table' => true
483+
'with_table' => true,
484484
]
485485
);
486486

server/src/Http/Controllers/Api/v1/PlaceController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function create(CreatePlaceRequest $request)
117117
'company_uuid' => session('company'),
118118
],
119119
[
120-
'with_table' => true
120+
'with_table' => true,
121121
]
122122
);
123123

@@ -228,7 +228,7 @@ public function update($id, UpdatePlaceRequest $request)
228228
'company_uuid' => session('company'),
229229
],
230230
[
231-
'with_table' => true
231+
'with_table' => true,
232232
]
233233
);
234234

server/src/Http/Requests/CreatePlaceRequest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public function rules()
3333
$hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
3434
$hasLocation = $this->filled('location');
3535
$hasStreet = $this->filled('street1');
36+
$hasAddress = $this->filled('address');
3637

3738
// if creating then it's required
3839
if ($isCreating) {
3940
// if either has coordinated or location then it's not required
40-
if ($hasCoordiantes || $hasLocation) {
41+
if ($hasCoordiantes || $hasLocation || $hasAddress) {
4142
return false;
4243
}
4344

@@ -57,11 +58,12 @@ public function rules()
5758
$isCreating = $this->isMethod('POST');
5859
$hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
5960
$hasLocation = $this->filled('location');
61+
$hasAddress = $this->filled('address');
6062

6163
// if creating then it's required
6264
if ($isCreating) {
6365
// if either has coordinated or location then it's not required
64-
if ($hasCoordiantes || $hasLocation) {
66+
if ($hasCoordiantes || $hasLocation || $hasAddress) {
6567
return false;
6668
}
6769

@@ -71,6 +73,7 @@ public function rules()
7173
return false;
7274
}),
7375
],
76+
'address' => ['nullable'],
7477
'customer' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
7578
'contact' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
7679
'vendor' => 'nullable|exists:vendors,public_id',

server/src/Support/Utils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ public static function getPointFromMixed($coordinates): ?Point
191191
$coordinates = $coordinates->location;
192192
}
193193

194+
if ($coordinates instanceof \Fleetbase\FleetOps\Models\Vehicle) {
195+
$coordinates = $coordinates->location;
196+
}
197+
194198
// any model with spatial location point
195199
if ($coordinates instanceof \Illuminate\Database\Eloquent\Model && $coordinates->isFillable('location')) {
196200
$coordinates = $coordinates->location;

0 commit comments

Comments
 (0)