@fleetbase/fleetops-engine 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/addon/components/admin/navigator-app.hbs +5 -0
- package/addon/components/admin/navigator-app.js +27 -0
- package/addon/components/driver-form-panel.js +13 -19
- package/addon/components/fleet-listing-panel.hbs +2 -2
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.hbs +1 -0
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +3 -0
- package/addon/components/layout/fleet-ops-sidebar.hbs +4 -4
- package/addon/components/layout/fleet-ops-sidebar.js +2 -0
- package/addon/components/leaflet-draw-control.js +2 -3
- package/addon/components/live-map.js +7 -4
- package/addon/components/modals/driver-assign-order.hbs +2 -2
- package/addon/components/modals/order-import.hbs +5 -5
- package/addon/components/modals/order-new-activity.hbs +1 -1
- package/addon/components/order-config/entities-editor.js +3 -5
- package/addon/components/route-list.hbs +2 -2
- package/addon/components/vendor-form-panel.js +1 -1
- package/addon/controllers/application.js +2 -2
- package/addon/controllers/base-controller.js +31 -0
- package/addon/controllers/management/contacts/index/details.js +2 -2
- package/addon/controllers/management/contacts/index/edit.js +2 -2
- package/addon/controllers/management/contacts/index/new.js +2 -2
- package/addon/controllers/management/contacts/index.js +9 -2
- package/addon/controllers/management/drivers/index/details.js +2 -2
- package/addon/controllers/management/drivers/index/edit.js +28 -2
- package/addon/controllers/management/drivers/index/new.js +2 -2
- package/addon/controllers/management/drivers/index.js +18 -24
- package/addon/controllers/management/fleets/index/details.js +2 -2
- package/addon/controllers/management/fleets/index/edit.js +2 -2
- package/addon/controllers/management/fleets/index/new.js +2 -2
- package/addon/controllers/management/fleets/index.js +16 -9
- package/addon/controllers/management/fuel-reports/index/details.js +2 -2
- package/addon/controllers/management/fuel-reports/index/edit.js +2 -2
- package/addon/controllers/management/fuel-reports/index/new.js +2 -2
- package/addon/controllers/management/fuel-reports/index.js +9 -2
- package/addon/controllers/management/issues/index/details.js +2 -2
- package/addon/controllers/management/issues/index/edit.js +2 -2
- package/addon/controllers/management/issues/index/new.js +2 -2
- package/addon/controllers/management/issues/index.js +9 -9
- package/addon/controllers/management/places/index/details.js +2 -2
- package/addon/controllers/management/places/index/edit.js +2 -2
- package/addon/controllers/management/places/index/new.js +2 -2
- package/addon/controllers/management/places/index.js +8 -2
- package/addon/controllers/management/vehicles/index/details.js +2 -2
- package/addon/controllers/management/vehicles/index/edit.js +2 -2
- package/addon/controllers/management/vehicles/index/new.js +2 -2
- package/addon/controllers/management/vehicles/index.js +24 -32
- package/addon/controllers/management/vendors/index/details.js +2 -2
- package/addon/controllers/management/vendors/index/edit.js +2 -2
- package/addon/controllers/management/vendors/index/new.js +2 -2
- package/addon/controllers/management/vendors/index.js +9 -8
- package/addon/controllers/management.js +2 -2
- package/addon/controllers/operations/orders/index/config/types.js +2 -2
- package/addon/controllers/operations/orders/index/config.js +2 -2
- package/addon/controllers/operations/orders/index/new.js +64 -44
- package/addon/controllers/operations/orders/index/view.js +11 -4
- package/addon/controllers/operations/orders/index.js +2 -2
- package/addon/controllers/operations/scheduler/index.js +2 -2
- package/addon/controllers/operations/service-rates/index/edit.js +12 -18
- package/addon/controllers/operations/service-rates/index/new.js +16 -22
- package/addon/controllers/operations/service-rates/index.js +9 -2
- package/addon/engine.js +6 -0
- package/addon/helpers/waypoint-label.js +6 -1
- package/addon/routes/application.js +4 -15
- package/addon/routes/management/contacts/index.js +9 -5
- package/addon/routes/management/drivers/index.js +7 -3
- package/addon/routes/management/fleets/index.js +9 -5
- package/addon/routes/management/fuel-reports/index.js +9 -5
- package/addon/routes/management/issues/index.js +9 -5
- package/addon/routes/management/places/index.js +9 -5
- package/addon/routes/management/vehicles/index/details.js +2 -2
- package/addon/routes/management/vehicles/index.js +11 -2
- package/addon/routes/management/vendors/index.js +9 -6
- package/addon/routes/operations/orders/index/view.js +6 -2
- package/addon/routes/operations/orders/index.js +7 -1
- package/addon/routes/operations/orders.js +0 -1
- package/addon/routes/operations/service-rates/index.js +9 -27
- package/addon/routes/operations/service-rates.js +1 -8
- package/addon/styles/fleetops-engine.css +14 -7
- package/addon/templates/management/contacts/index.hbs +1 -0
- package/addon/templates/management/drivers/index.hbs +2 -1
- package/addon/templates/management/fleets/index.hbs +23 -3
- package/addon/templates/management/fuel-reports/index.hbs +1 -0
- package/addon/templates/management/issues/index.hbs +22 -2
- package/addon/templates/management/places/index.hbs +9 -1
- package/addon/templates/management/vehicles/index.hbs +22 -2
- package/addon/templates/management/vendors/index.hbs +22 -2
- package/addon/templates/operations/orders/index/new.hbs +7 -7
- package/addon/templates/operations/orders/index/view.hbs +17 -16
- package/addon/templates/operations/service-rates/index.hbs +11 -3
- package/addon/utils/waypoint-label.js +3 -0
- package/app/components/layout/fleet-ops-sidebar/fleet-listing.js +1 -0
- package/app/controllers/{operations/zones/index.js → base-controller.js} +1 -1
- package/app/utils/waypoint-label.js +1 -0
- package/composer.json +1 -1
- package/config/environment.js +11 -1
- package/extension.json +1 -1
- package/index.js +1 -0
- package/package.json +47 -41
- package/server/migrations/2023_04_27_053456_create_contacts_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_drivers_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_entities_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_fleets_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_issues_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_orders_table.php +8 -8
- package/server/migrations/2023_04_27_053456_create_payloads_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_places_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_service_areas_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_rates_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_vehicles_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_vendors_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_waypoints_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_zones_table.php +2 -2
- package/server/migrations/2023_11_17_053001_add_category_uuid_to_entities_table.php +33 -0
- package/server/migrations/2023_11_28_074244_add_supplier_uuid_column_to_entities_table.php +33 -0
- package/server/migrations/2023_12_14_100209_add_meta_column_on_driver_table.php +30 -0
- package/server/src/Http/Controllers/Api/v1/DriverController.php +7 -4
- package/server/src/Http/Controllers/Api/v1/EntityController.php +2 -0
- package/server/src/Http/Controllers/Api/v1/OrderController.php +118 -42
- package/server/src/Http/Controllers/Api/v1/PayloadController.php +41 -43
- package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +43 -2
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +0 -1
- package/server/src/Http/Controllers/Internal/v1/MorphController.php +48 -16
- package/server/src/Http/Controllers/Internal/v1/NavigatorController.php +41 -0
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +3 -2
- package/server/src/Http/Controllers/Internal/v1/PlaceController.php +2 -2
- package/server/src/Http/Requests/CreateDriverRequest.php +2 -0
- package/server/src/Http/Requests/CreateOrderRequest.php +18 -4
- package/server/src/Http/Requests/CreatePayloadRequest.php +23 -7
- package/server/src/Http/Requests/CreatePlaceRequest.php +9 -5
- package/server/src/Http/Requests/CreateTrackingStatusRequest.php +69 -12
- package/server/src/Http/Requests/CreateVehicleRequest.php +5 -3
- package/server/src/Http/Resources/v1/Entity.php +3 -0
- package/server/src/Http/Resources/v1/Fleet.php +19 -17
- package/server/src/Http/Resources/v1/Order.php +3 -2
- package/server/src/Models/Driver.php +21 -2
- package/server/src/Models/Entity.php +18 -23
- package/server/src/Models/Order.php +2 -2
- package/server/src/Models/Payload.php +27 -9
- package/server/src/Models/Place.php +28 -5
- package/server/src/Models/TrackingStatus.php +9 -3
- package/server/src/Models/Vehicle.php +4 -2
- package/server/src/Models/VehicleDevice.php +28 -0
- package/server/src/Models/VehicleDeviceEvent.php +1 -1
- package/server/src/Models/Vendor.php +16 -0
- package/server/src/Observers/DriverObserver.php +1 -1
- package/server/src/routes.php +8 -0
- package/tsconfig.declarations.json +10 -0
- package/addon/components/file-icon.js +0 -1
- package/addon/controllers/operations/zones/index.js +0 -475
- package/addon/routes/operations/dispatch.js +0 -3
- package/addon/routes/operations/zones/index.js +0 -25
- package/addon/routes/operations/zones.js +0 -7
- package/addon/templates/operations/dispatch.hbs +0 -1
- package/addon/templates/operations/zones/index.hbs +0 -72
- package/addon/templates/operations/zones.hbs +0 -1
- package/app/components/file-icon.js +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
use Illuminate\Database\Migrations\Migration;
|
|
4
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
5
|
+
use Illuminate\Support\Facades\Schema;
|
|
6
|
+
|
|
7
|
+
class AddSupplierUuidColumnToEntitiesTable extends Migration
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Run the migrations.
|
|
11
|
+
*
|
|
12
|
+
* @return void
|
|
13
|
+
*/
|
|
14
|
+
public function up()
|
|
15
|
+
{
|
|
16
|
+
Schema::table('entities', function (Blueprint $table) {
|
|
17
|
+
$table->foreignUuid('supplier_uuid')->nullable()->after('driver_assigned_uuid')->references('uuid')->on('vendors');
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reverse the migrations.
|
|
23
|
+
*
|
|
24
|
+
* @return void
|
|
25
|
+
*/
|
|
26
|
+
public function down()
|
|
27
|
+
{
|
|
28
|
+
Schema::table('entities', function (Blueprint $table) {
|
|
29
|
+
$table->dropForeign(['supplier_uuid']);
|
|
30
|
+
$table->dropColumn(['supplier_uuid']);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
use Illuminate\Database\Migrations\Migration;
|
|
4
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
5
|
+
use Illuminate\Support\Facades\Schema;
|
|
6
|
+
|
|
7
|
+
class AddMetaColumnOnDriverTable extends Migration
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Run the migrations.
|
|
11
|
+
*
|
|
12
|
+
* @return void
|
|
13
|
+
*/
|
|
14
|
+
public function up()
|
|
15
|
+
{
|
|
16
|
+
Schema::table('drivers', function (Blueprint $table) {
|
|
17
|
+
$table->json('meta')->nullable()->after('slug');
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reverse the migrations.
|
|
23
|
+
*
|
|
24
|
+
* @return void
|
|
25
|
+
*/
|
|
26
|
+
public function down()
|
|
27
|
+
{
|
|
28
|
+
//
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -431,7 +431,10 @@ class DriverController extends Controller
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
// check if user exists
|
|
434
|
-
$user = User::where('
|
|
434
|
+
$user = User::where('type', 'driver')->where(function ($query) use ($identity) {
|
|
435
|
+
$query->where('phone', $identity);
|
|
436
|
+
$query->orWhere('phone', $identity);
|
|
437
|
+
})->first();
|
|
435
438
|
|
|
436
439
|
if (!$user) {
|
|
437
440
|
return response()->error('Unable to verify code.');
|
|
@@ -456,9 +459,9 @@ class DriverController extends Controller
|
|
|
456
459
|
[
|
|
457
460
|
'user_uuid' => $user->uuid,
|
|
458
461
|
'company_uuid' => $company->uuid,
|
|
459
|
-
'name' => $attrs
|
|
460
|
-
'phone' => $attrs
|
|
461
|
-
'email' => $attrs
|
|
462
|
+
'name' => data_get($attrs, 'name', $user->name),
|
|
463
|
+
'phone' => data_get($attrs, 'phone', $user->phone),
|
|
464
|
+
'email' => data_get($attrs, 'email', $user->email),
|
|
462
465
|
'location' => new Point(0, 0),
|
|
463
466
|
]
|
|
464
467
|
);
|
|
@@ -41,6 +41,7 @@ class EntityController extends Controller
|
|
|
41
41
|
'sku',
|
|
42
42
|
'currency',
|
|
43
43
|
'meta',
|
|
44
|
+
'supplier_uuid',
|
|
44
45
|
]);
|
|
45
46
|
|
|
46
47
|
// payload assignment
|
|
@@ -126,6 +127,7 @@ class EntityController extends Controller
|
|
|
126
127
|
'sku',
|
|
127
128
|
'currency',
|
|
128
129
|
'meta',
|
|
130
|
+
'supplier_uuid',
|
|
129
131
|
]);
|
|
130
132
|
|
|
131
133
|
// payload assignment
|
|
@@ -33,7 +33,7 @@ class OrderController extends Controller
|
|
|
33
33
|
/**
|
|
34
34
|
* Creates a new Fleetbase Order resource.
|
|
35
35
|
*
|
|
36
|
-
* @param \Fleetbase\Http\Requests\CreateOrderRequest $request
|
|
36
|
+
* @param \Illuminate\Http\Request|\Fleetbase\Http\Requests\CreateOrderRequest $request
|
|
37
37
|
*
|
|
38
38
|
* @return \Fleetbase\Http\Resources\Order
|
|
39
39
|
*/
|
|
@@ -61,18 +61,36 @@ class OrderController extends Controller
|
|
|
61
61
|
|
|
62
62
|
// create payload
|
|
63
63
|
if ($request->has('payload') && $request->isArray('payload')) {
|
|
64
|
-
$payloadInput = $request->input('payload');
|
|
65
64
|
$payload = new Payload();
|
|
65
|
+
$payloadInput = $request->input('payload');
|
|
66
|
+
$entities = data_get($payloadInput, 'entities', []);
|
|
67
|
+
$waypoints = data_get($payloadInput, 'waypoints', []);
|
|
68
|
+
$pickup = data_get($payloadInput, 'pickup');
|
|
69
|
+
$dropoff = data_get($payloadInput, 'dropoff');
|
|
70
|
+
$return = data_get($payloadInput, 'return');
|
|
71
|
+
|
|
72
|
+
// if no pickup and dropoff extract from waypoints
|
|
73
|
+
if (empty($pickup) && empty($dropoff) && count($waypoints)) {
|
|
74
|
+
$pickup = array_shift($waypoints);
|
|
75
|
+
$dropoff = array_pop($waypoints);
|
|
76
|
+
}
|
|
66
77
|
|
|
67
|
-
$payload->setPickup($
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
$payload->setPickup($pickup, [
|
|
79
|
+
'callback' => function ($pickup, $payload) {
|
|
80
|
+
$payload->setCurrentWaypoint($pickup);
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
83
|
+
$payload->setDropoff($dropoff);
|
|
84
|
+
if ($return) {
|
|
85
|
+
$payload->setReturn($return);
|
|
71
86
|
}
|
|
72
|
-
|
|
73
|
-
$payload->setEntities($payloadInput['entities'] ?? []);
|
|
87
|
+
|
|
74
88
|
$payload->save();
|
|
75
89
|
|
|
90
|
+
// set waypoints and entities after payload is saved
|
|
91
|
+
$payload->setWaypoints($waypoints);
|
|
92
|
+
$payload->setEntities($entities);
|
|
93
|
+
|
|
76
94
|
$input['payload_uuid'] = $payload->uuid;
|
|
77
95
|
} elseif ($request->isString('payload')) {
|
|
78
96
|
$input['payload_uuid'] = Utils::getUuid('payloads', [
|
|
@@ -84,19 +102,40 @@ class OrderController extends Controller
|
|
|
84
102
|
|
|
85
103
|
// create a payload if missing payload[] but has pickup/dropoff/etc
|
|
86
104
|
if ($request->missing('payload')) {
|
|
87
|
-
$payloadInput = $request->only(['pickup', 'dropoff', 'return', 'waypoints', 'entities']);
|
|
88
105
|
$payload = new Payload();
|
|
106
|
+
$payloadInput = $request->only(['pickup', 'dropoff', 'return', 'waypoints', 'entities']);
|
|
107
|
+
$entities = data_get($payloadInput, 'entities', []);
|
|
108
|
+
$waypoints = data_get($payloadInput, 'waypoints', []);
|
|
109
|
+
$pickup = data_get($payloadInput, 'pickup');
|
|
110
|
+
$dropoff = data_get($payloadInput, 'dropoff');
|
|
111
|
+
$return = data_get($payloadInput, 'return');
|
|
112
|
+
|
|
113
|
+
// if no pickup and dropoff extract from waypoints
|
|
114
|
+
if (empty($pickup) && empty($dropoff) && count($waypoints)) {
|
|
115
|
+
$pickup = array_shift($waypoints);
|
|
116
|
+
$dropoff = array_pop($waypoints);
|
|
117
|
+
}
|
|
89
118
|
|
|
90
|
-
$payload->setPickup($
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
$payload->setPickup($pickup, [
|
|
120
|
+
'callback' => function ($pickup, $payload) {
|
|
121
|
+
$payload->setCurrentWaypoint($pickup);
|
|
122
|
+
},
|
|
123
|
+
]);
|
|
124
|
+
$payload->setDropoff($dropoff);
|
|
125
|
+
if ($return) {
|
|
126
|
+
$payload->setReturn($return);
|
|
94
127
|
}
|
|
95
|
-
|
|
96
|
-
$payload->setEntities($payloadInput['entities'] ?? []);
|
|
128
|
+
|
|
97
129
|
$payload->save();
|
|
98
130
|
|
|
131
|
+
// set waypoints and entities after payload is saved
|
|
132
|
+
$payload->setWaypoints($waypoints);
|
|
133
|
+
$payload->setEntities($entities);
|
|
134
|
+
|
|
99
135
|
$input['payload_uuid'] = $payload->uuid;
|
|
136
|
+
|
|
137
|
+
// set the first / current waypoint
|
|
138
|
+
$payload->setCurrentWaypoint($payload->pickup);
|
|
100
139
|
}
|
|
101
140
|
|
|
102
141
|
// driver assignment
|
|
@@ -218,18 +257,43 @@ class OrderController extends Controller
|
|
|
218
257
|
|
|
219
258
|
// update payload if new input or change payload by id
|
|
220
259
|
if ($request->isArray('payload')) {
|
|
260
|
+
$payload = data_get($order, 'payload', new Payload());
|
|
221
261
|
$payloadInput = $request->input('payload');
|
|
222
|
-
$
|
|
262
|
+
$entities = data_get($payloadInput, 'entities', []);
|
|
263
|
+
$waypoints = data_get($payloadInput, 'waypoints', []);
|
|
264
|
+
$pickup = data_get($payloadInput, 'pickup');
|
|
265
|
+
$dropoff = data_get($payloadInput, 'dropoff');
|
|
266
|
+
$return = data_get($payloadInput, 'return');
|
|
267
|
+
|
|
268
|
+
// if no pickup and dropoff extract from waypoints
|
|
269
|
+
if (empty($pickup) && empty($dropoff) && count($waypoints)) {
|
|
270
|
+
$pickup = array_shift($waypoints);
|
|
271
|
+
$dropoff = array_pop($waypoints);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if ($pickup) {
|
|
275
|
+
$payload->setPickup($pickup);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if ($dropoff) {
|
|
279
|
+
$payload->setDropoff($dropoff);
|
|
280
|
+
}
|
|
223
281
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if ($request->has('payload.return')) {
|
|
227
|
-
$payload->setReturn($payloadInput['return']);
|
|
282
|
+
if ($return) {
|
|
283
|
+
$payload->setReturn($return);
|
|
228
284
|
}
|
|
229
|
-
|
|
230
|
-
$payload->setEntities($payloadInput['entities'] ?? []);
|
|
285
|
+
|
|
231
286
|
$payload->save();
|
|
232
287
|
|
|
288
|
+
// set waypoints and entities after payload is saved
|
|
289
|
+
if ($waypoints) {
|
|
290
|
+
$payload->setWaypoints($waypoints);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if ($entities) {
|
|
294
|
+
$payload->setEntities($entities);
|
|
295
|
+
}
|
|
296
|
+
|
|
233
297
|
$input['payload_uuid'] = $payload->uuid;
|
|
234
298
|
} elseif ($request->has('payload')) {
|
|
235
299
|
$input['payload_uuid'] = Utils::getUuid('payloads', [
|
|
@@ -239,34 +303,46 @@ class OrderController extends Controller
|
|
|
239
303
|
unset($input['payload']);
|
|
240
304
|
}
|
|
241
305
|
|
|
242
|
-
//
|
|
243
|
-
if ($request->
|
|
244
|
-
|
|
245
|
-
|
|
306
|
+
// create a payload if missing payload[] but has pickup/dropoff/etc
|
|
307
|
+
if ($request->missing('payload')) {
|
|
308
|
+
$payload = data_get($order, 'payload', new Payload());
|
|
309
|
+
$payloadInput = $request->only(['pickup', 'dropoff', 'return', 'waypoints', 'entities']);
|
|
310
|
+
$entities = data_get($payloadInput, 'entities', []);
|
|
311
|
+
$waypoints = data_get($payloadInput, 'waypoints', []);
|
|
312
|
+
$pickup = data_get($payloadInput, 'pickup');
|
|
313
|
+
$dropoff = data_get($payloadInput, 'dropoff');
|
|
314
|
+
$return = data_get($payloadInput, 'return');
|
|
315
|
+
|
|
316
|
+
// if no pickup and dropoff extract from waypoints
|
|
317
|
+
if (empty($pickup) && empty($dropoff) && count($waypoints)) {
|
|
318
|
+
$pickup = array_shift($waypoints);
|
|
319
|
+
$dropoff = array_pop($waypoints);
|
|
246
320
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
$order->payload->setDropoff($request->input('dropoff'));
|
|
321
|
+
|
|
322
|
+
if ($pickup) {
|
|
323
|
+
$payload->setPickup($pickup);
|
|
251
324
|
}
|
|
252
|
-
}
|
|
253
325
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
$order->payload->setReturn($request->input('return'));
|
|
326
|
+
if ($dropoff) {
|
|
327
|
+
$payload->setDropoff($dropoff);
|
|
257
328
|
}
|
|
258
|
-
}
|
|
259
329
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
$order->payload->setWaypoints($request->input('waypoints'));
|
|
330
|
+
if ($return) {
|
|
331
|
+
$payload->setReturn($return);
|
|
263
332
|
}
|
|
264
|
-
}
|
|
265
333
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
334
|
+
$payload->save();
|
|
335
|
+
|
|
336
|
+
// set waypoints and entities after payload is saved
|
|
337
|
+
if ($waypoints) {
|
|
338
|
+
$payload->setWaypoints($waypoints);
|
|
269
339
|
}
|
|
340
|
+
|
|
341
|
+
if ($entities) {
|
|
342
|
+
$payload->setEntities($entities);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
$input['payload_uuid'] = $payload->uuid;
|
|
270
346
|
}
|
|
271
347
|
|
|
272
348
|
// driver assignment
|
|
@@ -7,10 +7,9 @@ use Fleetbase\FleetOps\Http\Requests\UpdatePayloadRequest;
|
|
|
7
7
|
use Fleetbase\FleetOps\Http\Resources\v1\DeletedResource;
|
|
8
8
|
use Fleetbase\FleetOps\Http\Resources\v1\Payload as PayloadResource;
|
|
9
9
|
use Fleetbase\FleetOps\Models\Payload;
|
|
10
|
-
use Fleetbase\FleetOps\Models\Place;
|
|
11
|
-
use Fleetbase\FleetOps\Models\Waypoint;
|
|
12
10
|
use Fleetbase\Http\Controllers\Controller;
|
|
13
11
|
use Illuminate\Http\Request;
|
|
12
|
+
use Illuminate\Support\Arr;
|
|
14
13
|
|
|
15
14
|
// use Fleetbase\FleetOps\Support\Utils;
|
|
16
15
|
|
|
@@ -25,41 +24,42 @@ class PayloadController extends Controller
|
|
|
25
24
|
*/
|
|
26
25
|
public function create(CreatePayloadRequest $request)
|
|
27
26
|
{
|
|
28
|
-
|
|
29
|
-
$
|
|
27
|
+
$input = $request->all();
|
|
28
|
+
$entities = data_get($input, 'entities', []);
|
|
29
|
+
$waypoints = data_get($input, 'waypoints', []);
|
|
30
|
+
$pickup = data_get($input, 'pickup');
|
|
31
|
+
$dropoff = data_get($input, 'dropoff');
|
|
32
|
+
$return = data_get($input, 'return');
|
|
30
33
|
|
|
31
34
|
// make sure company is set
|
|
32
35
|
$input['company_uuid'] = session('company');
|
|
33
36
|
|
|
34
37
|
// create the payload
|
|
35
|
-
$payload = new Payload($input);
|
|
38
|
+
$payload = new Payload(Arr::only($input, ['type', 'provider', 'meta', 'cod_amount', 'cod_currency', 'cod_payment_method']));
|
|
39
|
+
|
|
40
|
+
// if no pickup and dropoff extract from waypoints
|
|
41
|
+
if (empty($pickup) && empty($dropoff) && count($waypoints)) {
|
|
42
|
+
$pickup = array_shift($waypoints);
|
|
43
|
+
$dropoff = array_pop($waypoints);
|
|
44
|
+
}
|
|
36
45
|
|
|
37
46
|
// set pickup point
|
|
38
|
-
$payload->setPickup($
|
|
47
|
+
$payload->setPickup($pickup);
|
|
39
48
|
|
|
40
49
|
// set dropoff point
|
|
41
|
-
$payload->setDropoff($
|
|
50
|
+
$payload->setDropoff($dropoff);
|
|
42
51
|
|
|
43
52
|
// set return point
|
|
44
|
-
$payload->setReturn($
|
|
53
|
+
$payload->setReturn($return);
|
|
45
54
|
|
|
46
55
|
// save payload
|
|
47
56
|
$payload->save();
|
|
48
57
|
|
|
49
58
|
// set waypoints
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// create waypoint
|
|
56
|
-
Waypoint::create([
|
|
57
|
-
'place_uuid' => $id,
|
|
58
|
-
'payload_uuid' => $payload->uuid,
|
|
59
|
-
'order' => $index,
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
59
|
+
$payload->setWaypoints($waypoints);
|
|
60
|
+
|
|
61
|
+
// set entities
|
|
62
|
+
$payload->setEntities($entities);
|
|
63
63
|
|
|
64
64
|
// response the driver resource
|
|
65
65
|
return new PayloadResource($payload);
|
|
@@ -88,42 +88,40 @@ class PayloadController extends Controller
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// get request input
|
|
91
|
-
$input
|
|
91
|
+
$input = $request->all();
|
|
92
|
+
$entities = data_get($input, 'entities', []);
|
|
93
|
+
$waypoints = data_get($input, 'waypoints', []);
|
|
94
|
+
$pickup = data_get($input, 'pickup');
|
|
95
|
+
$dropoff = data_get($input, 'dropoff');
|
|
96
|
+
$return = data_get($input, 'return');
|
|
92
97
|
|
|
93
98
|
// pickup assignment
|
|
94
|
-
if ($
|
|
95
|
-
$payload->setPickup($
|
|
99
|
+
if ($pickup) {
|
|
100
|
+
$payload->setPickup($pickup);
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
// dropoff assignment
|
|
99
|
-
if ($
|
|
100
|
-
$payload->setDropoff($
|
|
104
|
+
if ($dropoff) {
|
|
105
|
+
$payload->setDropoff($dropoff);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
// return assignment
|
|
104
|
-
if ($
|
|
105
|
-
$payload->setReturn($
|
|
109
|
+
if ($return) {
|
|
110
|
+
$payload->setReturn($return);
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
// set waypoints
|
|
109
|
-
if ($
|
|
110
|
-
$
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// create waypoint
|
|
117
|
-
Waypoint::create([
|
|
118
|
-
'place_uuid' => $id,
|
|
119
|
-
'payload_uuid' => $payload->uuid,
|
|
120
|
-
'order' => $index + $waypointCount,
|
|
121
|
-
]);
|
|
122
|
-
}
|
|
114
|
+
if ($waypoints) {
|
|
115
|
+
$payload->setWaypoints($waypoints);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// set entities
|
|
119
|
+
if ($entities) {
|
|
120
|
+
$payload->setEntities($entities);
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
// update the payload
|
|
126
|
-
$payload->fill($input);
|
|
124
|
+
$payload->fill(array_filter(Arr::only($input, ['type', 'provider', 'meta', 'cod_amount', 'cod_currency', 'cod_payment_method'])));
|
|
127
125
|
|
|
128
126
|
// save the payload
|
|
129
127
|
$payload->save();
|
|
@@ -6,9 +6,11 @@ use Fleetbase\FleetOps\Http\Requests\CreateTrackingStatusRequest;
|
|
|
6
6
|
use Fleetbase\FleetOps\Http\Requests\UpdateTrackingStatusRequest;
|
|
7
7
|
use Fleetbase\FleetOps\Http\Resources\v1\DeletedResource;
|
|
8
8
|
use Fleetbase\FleetOps\Http\Resources\v1\TrackingStatus as TrackingStatusResource;
|
|
9
|
+
use Fleetbase\FleetOps\Models\Order;
|
|
9
10
|
use Fleetbase\FleetOps\Models\TrackingStatus;
|
|
10
11
|
use Fleetbase\FleetOps\Support\Utils;
|
|
11
12
|
use Fleetbase\Http\Controllers\Controller;
|
|
13
|
+
use Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
12
14
|
use Illuminate\Http\Request;
|
|
13
15
|
|
|
14
16
|
class TrackingStatusController extends Controller
|
|
@@ -23,7 +25,24 @@ class TrackingStatusController extends Controller
|
|
|
23
25
|
public function create(CreateTrackingStatusRequest $request)
|
|
24
26
|
{
|
|
25
27
|
// get request input
|
|
26
|
-
$input = $request->only(['status', 'details', 'code', 'city', 'province', 'postal_code', 'country', 'latitude', 'longitude']);
|
|
28
|
+
$input = $request->only(['status', 'details', 'code', 'city', 'province', 'postal_code', 'country', 'location', 'latitude', 'longitude']);
|
|
29
|
+
|
|
30
|
+
// if no location provided but latitude/longitude
|
|
31
|
+
if (empty($input['location']) && isset($input['latitude']) && isset($input['longitude'])) {
|
|
32
|
+
$latitude = data_get($input, 'latitude');
|
|
33
|
+
$longitude = data_get($input, 'longitude');
|
|
34
|
+
|
|
35
|
+
// unset latitude and longitude
|
|
36
|
+
unset($input['latitude'], $input['longitude']);
|
|
37
|
+
|
|
38
|
+
// create location
|
|
39
|
+
$input['location'] = new Point($latitude, $longitude);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// if no code set create a code from the status
|
|
43
|
+
if (empty($input['code'])) {
|
|
44
|
+
$input['code'] = TrackingStatus::prepareCode($input['status']);
|
|
45
|
+
}
|
|
27
46
|
|
|
28
47
|
// make sure company is set
|
|
29
48
|
$input['company_uuid'] = session('company');
|
|
@@ -36,6 +55,11 @@ class TrackingStatusController extends Controller
|
|
|
36
55
|
]);
|
|
37
56
|
}
|
|
38
57
|
|
|
58
|
+
// tracking number assignment
|
|
59
|
+
if ($request->has('order')) {
|
|
60
|
+
$input['tracking_number_uuid'] = Order::where('public_id', $request->input('order'))->value('tracking_number_uuid');
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
// create the trackingStatus
|
|
40
64
|
$trackingStatus = TrackingStatus::create($input);
|
|
41
65
|
|
|
@@ -66,7 +90,24 @@ class TrackingStatusController extends Controller
|
|
|
66
90
|
}
|
|
67
91
|
|
|
68
92
|
// get request input
|
|
69
|
-
$input = $request->only(['status', 'details', 'code', 'city', 'province', 'postal_code', 'country', 'latitude', 'longitude']);
|
|
93
|
+
$input = $request->only(['status', 'details', 'code', 'city', 'province', 'postal_code', 'country', 'location', 'latitude', 'longitude']);
|
|
94
|
+
|
|
95
|
+
// if no location provided but latitude/longitude
|
|
96
|
+
if (empty($input['location']) && isset($input['latitude']) && isset($input['longitude'])) {
|
|
97
|
+
$latitude = data_get($input, 'latitude');
|
|
98
|
+
$longitude = data_get($input, 'longitude');
|
|
99
|
+
|
|
100
|
+
// unset latitude and longitude
|
|
101
|
+
unset($input['latitude'], $input['longitude']);
|
|
102
|
+
|
|
103
|
+
// create location
|
|
104
|
+
$input['location'] = new Point($latitude, $longitude);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// if no code set create a code from the status
|
|
108
|
+
if (empty($input['code'])) {
|
|
109
|
+
$input['code'] = TrackingStatus::prepareCode($input['status']);
|
|
110
|
+
}
|
|
70
111
|
|
|
71
112
|
// update the trackingStatus
|
|
72
113
|
$trackingStatus->update($input);
|
|
@@ -13,7 +13,6 @@ use Fleetbase\Http\Requests\ExportRequest;
|
|
|
13
13
|
use Fleetbase\Models\Invite;
|
|
14
14
|
use Fleetbase\Models\User;
|
|
15
15
|
use Fleetbase\Notifications\UserInvited;
|
|
16
|
-
use Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
17
16
|
use Illuminate\Http\Request;
|
|
18
17
|
use Illuminate\Support\Facades\DB;
|
|
19
18
|
use Illuminate\Support\Facades\Validator;
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Http\Filter\ContactFilter;
|
|
6
|
+
use Fleetbase\FleetOps\Http\Filter\VendorFilter;
|
|
5
7
|
use Fleetbase\FleetOps\Models\Contact;
|
|
6
8
|
use Fleetbase\FleetOps\Models\IntegratedVendor;
|
|
7
9
|
use Fleetbase\FleetOps\Models\Vendor;
|
|
8
10
|
use Fleetbase\FleetOps\Support\Utils;
|
|
9
11
|
use Fleetbase\Http\Controllers\Controller;
|
|
10
12
|
use Illuminate\Http\Request;
|
|
13
|
+
use Illuminate\Pagination\LengthAwarePaginator;
|
|
14
|
+
use Illuminate\Support\Facades\URL;
|
|
11
15
|
use Illuminate\Support\Str;
|
|
12
16
|
|
|
13
17
|
class MorphController extends Controller
|
|
@@ -21,18 +25,26 @@ class MorphController extends Controller
|
|
|
21
25
|
{
|
|
22
26
|
$query = $request->input('query');
|
|
23
27
|
$limit = $request->input('limit', 12);
|
|
28
|
+
$page = $request->input('page', 1);
|
|
24
29
|
$type = Str::lower($request->segment(4));
|
|
25
30
|
$resourceType = Str::lower(Utils::singularize($type));
|
|
26
31
|
|
|
27
|
-
$
|
|
32
|
+
$contactsQuery = Contact::searchWhere('name', $query)
|
|
28
33
|
->where('company_uuid', session('company'))
|
|
29
|
-
->
|
|
30
|
-
->get();
|
|
34
|
+
->filter(new ContactFilter($request));
|
|
31
35
|
|
|
32
|
-
$
|
|
36
|
+
$vendorsQuery = Vendor::searchWhere('name', $query)
|
|
33
37
|
->where('company_uuid', session('company'))
|
|
34
|
-
->
|
|
35
|
-
|
|
38
|
+
->filter(new VendorFilter($request));
|
|
39
|
+
|
|
40
|
+
// Get total count for pagination
|
|
41
|
+
$totalContacts = $contactsQuery->count();
|
|
42
|
+
$totalVendors = $vendorsQuery->count();
|
|
43
|
+
$total = $totalContacts + $totalVendors;
|
|
44
|
+
|
|
45
|
+
// Get paginated items
|
|
46
|
+
$contacts = $contactsQuery->limit($limit)->get();
|
|
47
|
+
$vendors = $vendorsQuery->limit($limit)->get();
|
|
36
48
|
|
|
37
49
|
$results = collect([...$contacts, ...$vendors])
|
|
38
50
|
->sortBy('name')
|
|
@@ -59,19 +71,39 @@ class MorphController extends Controller
|
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
|
|
62
|
-
// convert to array
|
|
63
|
-
$results = $results->toArray();
|
|
64
|
-
|
|
65
74
|
// set resource type
|
|
66
|
-
$results =
|
|
67
|
-
function ($
|
|
68
|
-
$
|
|
75
|
+
$results = $results->map(
|
|
76
|
+
function ($item) use ($resourceType) {
|
|
77
|
+
$item['type'] = $resourceType;
|
|
69
78
|
|
|
70
|
-
return $
|
|
71
|
-
}
|
|
72
|
-
$results
|
|
79
|
+
return $item;
|
|
80
|
+
}
|
|
73
81
|
);
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
// Create a LengthAwarePaginator instance
|
|
84
|
+
$results = new LengthAwarePaginator(
|
|
85
|
+
$results->forPage($page, $limit),
|
|
86
|
+
$total,
|
|
87
|
+
$limit,
|
|
88
|
+
$page,
|
|
89
|
+
['path' => URL::current()]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Manually structure the response
|
|
93
|
+
$response = [
|
|
94
|
+
$type => $results->items(),
|
|
95
|
+
'meta' => [
|
|
96
|
+
'total' => $results->total(),
|
|
97
|
+
'per_page' => $results->perPage(),
|
|
98
|
+
'current_page' => $results->currentPage(),
|
|
99
|
+
'last_page' => $results->lastPage(),
|
|
100
|
+
'next_page_url' => $results->nextPageUrl(),
|
|
101
|
+
'prev_page_url' => $results->previousPageUrl(),
|
|
102
|
+
'from' => $results->firstItem(),
|
|
103
|
+
'to' => $results->lastItem(),
|
|
104
|
+
],
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
return response()->json($response);
|
|
76
108
|
}
|
|
77
109
|
}
|