Skip to content

Commit 9a8447c

Browse files
authored
Merge pull request #153 from fleetbase/dev-v0.6.7
Dev v0.6.7 - Patched customer/facilitator assignment on order creation API & minor Place creation API patch
2 parents b5bb38e + 989188e commit 9a8447c

7 files changed

Lines changed: 34 additions & 6 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/fleetops-api",
3-
"version": "0.6.6",
3+
"version": "0.6.7",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"keywords": [
66
"fleetbase-extension",

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Fleet-Ops",
3-
"version": "0.6.6",
3+
"version": "0.6.7",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"repository": "https://github.com/fleetbase/fleetops",
66
"license": "AGPL-3.0-or-later",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fleetbase/fleetops-engine",
3-
"version": "0.6.6",
3+
"version": "0.6.7",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"fleetbase": {
66
"route": "fleet-ops"

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public function create(CreateOrderRequest $request)
195195
[
196196
'public_id' => $request->input('facilitator'),
197197
'company_uuid' => session('company'),
198+
],
199+
[
200+
'with_table' => true,
198201
]
199202
);
200203

@@ -217,6 +220,9 @@ public function create(CreateOrderRequest $request)
217220
[
218221
'public_id' => $customer,
219222
'company_uuid' => session('company'),
223+
],
224+
[
225+
'with_table' => true,
220226
]
221227
);
222228

@@ -256,6 +262,10 @@ public function create(CreateOrderRequest $request)
256262
}
257263
}
258264

265+
if (Str::isUuid($customer)) {
266+
$customer = Contact::where('uuid', $customer)->first();
267+
}
268+
259269
if ($customer instanceof Contact) {
260270
$input['customer_uuid'] = $customer->uuid;
261271
$input['customer_type'] = Utils::getModelClassName($customer);
@@ -449,6 +459,9 @@ public function update($id, UpdateOrderRequest $request)
449459
[
450460
'public_id' => $request->input('facilitator'),
451461
'company_uuid' => session('company'),
462+
],
463+
[
464+
'with_table' => true,
452465
]
453466
);
454467

@@ -465,6 +478,9 @@ public function update($id, UpdateOrderRequest $request)
465478
[
466479
'public_id' => $request->input('customer'),
467480
'company_uuid' => session('company'),
481+
],
482+
[
483+
'with_table' => true,
468484
]
469485
);
470486

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public function create(CreatePlaceRequest $request)
116116
'public_id' => $id,
117117
'company_uuid' => session('company'),
118118
],
119-
['full' => true]
119+
[
120+
'with_table' => true,
121+
]
120122
);
121123

122124
if (is_array($owner)) {
@@ -224,6 +226,9 @@ public function update($id, UpdatePlaceRequest $request)
224226
[
225227
'public_id' => $id,
226228
'company_uuid' => session('company'),
229+
],
230+
[
231+
'with_table' => true,
227232
]
228233
);
229234

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)