@fleetbase/fleetops-engine 0.2.6 → 0.2.7
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/.gitattributes +14 -0
- package/.php-cs-fixer.cache +1 -0
- package/.php-cs-fixer.php +29 -0
- package/LICENSE.md +16 -4
- package/README.md +103 -13
- package/composer.json +85 -0
- package/extension.json +10 -0
- package/package.json +3 -3
- package/phpstan.neon.dist +8 -0
- package/phpunit.xml.dist +16 -0
- package/server/config/api.php +765 -0
- package/server/config/cache.stores.php +18 -0
- package/server/config/dompdf.php +242 -0
- package/server/config/fleetops.php +19 -0
- package/server/config/geocoder.php +108 -0
- package/server/data/globe.json +261 -0
- package/server/migrations/2023_04_27_053456_create_contacts_table.php +49 -0
- package/server/migrations/2023_04_27_053456_create_drivers_table.php +62 -0
- package/server/migrations/2023_04_27_053456_create_entities_table.php +67 -0
- package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +39 -0
- package/server/migrations/2023_04_27_053456_create_fleets_table.php +47 -0
- package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +50 -0
- package/server/migrations/2023_04_27_053456_create_integrated_vendors_table.php +44 -0
- package/server/migrations/2023_04_27_053456_create_issues_table.php +53 -0
- package/server/migrations/2023_04_27_053456_create_orders_table.php +70 -0
- package/server/migrations/2023_04_27_053456_create_payloads_table.php +51 -0
- package/server/migrations/2023_04_27_053456_create_places_table.php +62 -0
- package/server/migrations/2023_04_27_053456_create_positions_table.php +46 -0
- package/server/migrations/2023_04_27_053456_create_proofs_table.php +44 -0
- package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +46 -0
- package/server/migrations/2023_04_27_053456_create_routes_table.php +40 -0
- package/server/migrations/2023_04_27_053456_create_service_areas_table.php +47 -0
- package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +42 -0
- package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +47 -0
- package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +45 -0
- package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +47 -0
- package/server/migrations/2023_04_27_053456_create_service_rates_table.php +61 -0
- package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +46 -0
- package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +54 -0
- package/server/migrations/2023_04_27_053456_create_vehicles_table.php +84 -0
- package/server/migrations/2023_04_27_053456_create_vendors_table.php +56 -0
- package/server/migrations/2023_04_27_053456_create_waypoints_table.php +45 -0
- package/server/migrations/2023_04_27_053456_create_zones_table.php +46 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_companies_table.php +32 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_contacts_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_drivers_table.php +40 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_entities_table.php +40 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleet_drivers_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleets_table.php +36 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fuel_reports_table.php +36 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_integrated_vendors_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_issues_table.php +38 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_orders_table.php +48 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_payloads_table.php +40 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_places_table.php +32 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_positions_table.php +36 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_proofs_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_purchase_rates_table.php +38 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_routes_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_areas_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quote_items_table.php +32 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quotes_table.php +38 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_fees_table.php +32 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_parcel_fees_table.php +32 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rates_table.php +36 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_numbers_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_statuses_table.php +34 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vehicles_table.php +36 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vendors_table.php +40 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_waypoints_table.php +38 -0
- package/server/migrations/2023_04_27_053459_add_foreign_keys_to_zones_table.php +34 -0
- package/server/migrations/2023_09_14_074512_update_vehicles_table.php +100 -0
- package/server/migrations/2023_09_14_074619_create_vehicle_devices_table.php +44 -0
- package/server/migrations/2023_09_26_071205_add_online_column_to_vehicles_table.php +32 -0
- package/server/migrations/2023_09_26_083957_create_fleet_vehicles_table.php +45 -0
- package/server/migrations/2023_09_27_023757_add_column_to_fleets_table.php +46 -0
- package/server/migrations/2023_10_05_074811_update_vehicle.php +42 -0
- package/server/resources/views/labels/default.php +165 -0
- package/server/src/Auth/Schemas/FleetOps.php +75 -0
- package/server/src/Casts/MultiPolygon.php +50 -0
- package/server/src/Casts/Point.php +109 -0
- package/server/src/Casts/Polygon.php +46 -0
- package/server/src/Console/Commands/DispatchAdhocOrders.php +137 -0
- package/server/src/Console/Commands/DispatchOrders.php +71 -0
- package/server/src/Console/Commands/TrackOrderDistanceAndTime.php +62 -0
- package/server/src/Events/DriverLocationChanged.php +174 -0
- package/server/src/Events/DriverSimulatedLocationChanged.php +183 -0
- package/server/src/Events/EntityDriverAssigned.php +36 -0
- package/server/src/Events/OrderCanceled.php +15 -0
- package/server/src/Events/OrderCompleted.php +15 -0
- package/server/src/Events/OrderDispatchFailed.php +42 -0
- package/server/src/Events/OrderDispatched.php +15 -0
- package/server/src/Events/OrderDriverAssigned.php +15 -0
- package/server/src/Events/OrderReady.php +15 -0
- package/server/src/Events/OrderStarted.php +15 -0
- package/server/src/Exceptions/IntegratedVendorException.php +18 -0
- package/server/src/Expansions/UserExpansion.php +63 -0
- package/server/src/Exports/ContactExport.php +56 -0
- package/server/src/Exports/DriverExport.php +61 -0
- package/server/src/Exports/FleetExport.php +53 -0
- package/server/src/Exports/PlaceExport.php +55 -0
- package/server/src/Exports/ServiceAreaExport.php +58 -0
- package/server/src/Exports/VehicleExport.php +57 -0
- package/server/src/Exports/VendorExport.php +57 -0
- package/server/src/Http/Controllers/Api/v1/ContactController.php +133 -0
- package/server/src/Http/Controllers/Api/v1/DriverController.php +691 -0
- package/server/src/Http/Controllers/Api/v1/EntityController.php +230 -0
- package/server/src/Http/Controllers/Api/v1/FleetController.php +146 -0
- package/server/src/Http/Controllers/Api/v1/LabelController.php +63 -0
- package/server/src/Http/Controllers/Api/v1/OrderController.php +1114 -0
- package/server/src/Http/Controllers/Api/v1/PayloadController.php +195 -0
- package/server/src/Http/Controllers/Api/v1/PlaceController.php +333 -0
- package/server/src/Http/Controllers/Api/v1/PurchaseRateController.php +199 -0
- package/server/src/Http/Controllers/Api/v1/ServiceAreaController.php +133 -0
- package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +381 -0
- package/server/src/Http/Controllers/Api/v1/ServiceRateController.php +223 -0
- package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +146 -0
- package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +138 -0
- package/server/src/Http/Controllers/Api/v1/VehicleController.php +191 -0
- package/server/src/Http/Controllers/Api/v1/VendorController.php +159 -0
- package/server/src/Http/Controllers/Api/v1/ZoneController.php +146 -0
- package/server/src/Http/Controllers/FleetOpsController.php +13 -0
- package/server/src/Http/Controllers/Internal/v1/ContactController.php +69 -0
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +261 -0
- package/server/src/Http/Controllers/Internal/v1/EntityController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/FleetController.php +152 -0
- package/server/src/Http/Controllers/Internal/v1/FleetOpsLookupController.php +80 -0
- package/server/src/Http/Controllers/Internal/v1/FuelReportController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/GeocoderController.php +96 -0
- package/server/src/Http/Controllers/Internal/v1/IntegratedVendorController.php +63 -0
- package/server/src/Http/Controllers/Internal/v1/IssueController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +127 -0
- package/server/src/Http/Controllers/Internal/v1/MetricsController.php +75 -0
- package/server/src/Http/Controllers/Internal/v1/MorphController.php +77 -0
- package/server/src/Http/Controllers/Internal/v1/OrderConfigController.php +269 -0
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +564 -0
- package/server/src/Http/Controllers/Internal/v1/PayloadController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/PlaceController.php +163 -0
- package/server/src/Http/Controllers/Internal/v1/ProofController.php +139 -0
- package/server/src/Http/Controllers/Internal/v1/PurchaseRateController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/RouteController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php +32 -0
- package/server/src/Http/Controllers/Internal/v1/ServiceQuoteController.php +345 -0
- package/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +47 -0
- package/server/src/Http/Controllers/Internal/v1/SettingController.php +30 -0
- package/server/src/Http/Controllers/Internal/v1/TrackingNumberController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/TrackingStatusController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/VehicleController.php +65 -0
- package/server/src/Http/Controllers/Internal/v1/VehicleDeviceController.php +15 -0
- package/server/src/Http/Controllers/Internal/v1/VendorController.php +120 -0
- package/server/src/Http/Controllers/Internal/v1/ZoneController.php +15 -0
- package/server/src/Http/Filter/ContactFilter.php +86 -0
- package/server/src/Http/Filter/DriverFilter.php +148 -0
- package/server/src/Http/Filter/FleetFilter.php +108 -0
- package/server/src/Http/Filter/IntegratedVendorFilter.php +13 -0
- package/server/src/Http/Filter/OrderFilter.php +242 -0
- package/server/src/Http/Filter/PlaceFilter.php +111 -0
- package/server/src/Http/Filter/ServiceAreaFilter.php +13 -0
- package/server/src/Http/Filter/ServiceQuoteFilter.php +13 -0
- package/server/src/Http/Filter/ServiceRateFilter.php +33 -0
- package/server/src/Http/Filter/TrackingStatusFilter.php +43 -0
- package/server/src/Http/Filter/VehicleFilter.php +91 -0
- package/server/src/Http/Filter/VendorFilter.php +83 -0
- package/server/src/Http/Filter/ZoneFilter.php +13 -0
- package/server/src/Http/Requests/CancelOrderRequest.php +31 -0
- package/server/src/Http/Requests/CreateContactRequest.php +33 -0
- package/server/src/Http/Requests/CreateDriverRequest.php +55 -0
- package/server/src/Http/Requests/CreateEntityRequest.php +43 -0
- package/server/src/Http/Requests/CreateFleetRequest.php +32 -0
- package/server/src/Http/Requests/CreateOrderRequest.php +66 -0
- package/server/src/Http/Requests/CreatePayloadRequest.php +37 -0
- package/server/src/Http/Requests/CreatePlaceRequest.php +38 -0
- package/server/src/Http/Requests/CreatePurchaseRateRequest.php +33 -0
- package/server/src/Http/Requests/CreateServiceAreaRequest.php +35 -0
- package/server/src/Http/Requests/CreateServiceQuoteRequest.php +29 -0
- package/server/src/Http/Requests/CreateServiceRateRequest.php +56 -0
- package/server/src/Http/Requests/CreateTrackingNumberRequest.php +34 -0
- package/server/src/Http/Requests/CreateTrackingStatusRequest.php +42 -0
- package/server/src/Http/Requests/CreateVehicleRequest.php +32 -0
- package/server/src/Http/Requests/CreateVendorRequest.php +35 -0
- package/server/src/Http/Requests/CreateZoneRequest.php +35 -0
- package/server/src/Http/Requests/DecodeTrackingNumberQR.php +30 -0
- package/server/src/Http/Requests/DriverSimulationRequest.php +46 -0
- package/server/src/Http/Requests/Internal/AssignOrderRequest.php +31 -0
- package/server/src/Http/Requests/Internal/CreateDriverRequest.php +42 -0
- package/server/src/Http/Requests/Internal/FleetActionRequest.php +32 -0
- package/server/src/Http/Requests/Internal/UpdateDriverRequest.php +7 -0
- package/server/src/Http/Requests/QueryServiceQuotesRequest.php +41 -0
- package/server/src/Http/Requests/UpdateContactRequest.php +20 -0
- package/server/src/Http/Requests/UpdateDriverRequest.php +7 -0
- package/server/src/Http/Requests/UpdateEntityRequest.php +7 -0
- package/server/src/Http/Requests/UpdateFleetRequest.php +7 -0
- package/server/src/Http/Requests/UpdateOrderRequest.php +7 -0
- package/server/src/Http/Requests/UpdatePayloadRequest.php +7 -0
- package/server/src/Http/Requests/UpdatePlaceRequest.php +7 -0
- package/server/src/Http/Requests/UpdatePurchaseRateRequest.php +7 -0
- package/server/src/Http/Requests/UpdateServiceAreaRequest.php +29 -0
- package/server/src/Http/Requests/UpdateServiceQuoteRequest.php +29 -0
- package/server/src/Http/Requests/UpdateServiceRateRequest.php +29 -0
- package/server/src/Http/Requests/UpdateTrackingNumberRequest.php +7 -0
- package/server/src/Http/Requests/UpdateTrackingStatusRequest.php +32 -0
- package/server/src/Http/Requests/UpdateVehicleRequest.php +7 -0
- package/server/src/Http/Requests/UpdateVendorRequest.php +7 -0
- package/server/src/Http/Requests/UpdateZoneRequest.php +7 -0
- package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +37 -0
- package/server/src/Http/Resources/Internal/v1/Vehicle.php +33 -0
- package/server/src/Http/Resources/Internal/v1/Waypoint.php +34 -0
- package/server/src/Http/Resources/v1/Contact.php +62 -0
- package/server/src/Http/Resources/v1/CurrentJob.php +36 -0
- package/server/src/Http/Resources/v1/DeletedResource.php +61 -0
- package/server/src/Http/Resources/v1/Driver.php +89 -0
- package/server/src/Http/Resources/v1/Entity.php +107 -0
- package/server/src/Http/Resources/v1/Fleet.php +60 -0
- package/server/src/Http/Resources/v1/FuelReport.php +67 -0
- package/server/src/Http/Resources/v1/Order.php +131 -0
- package/server/src/Http/Resources/v1/Payload.php +94 -0
- package/server/src/Http/Resources/v1/Place.php +84 -0
- package/server/src/Http/Resources/v1/Proof.php +36 -0
- package/server/src/Http/Resources/v1/PurchaseRate.php +77 -0
- package/server/src/Http/Resources/v1/ServiceArea.php +55 -0
- package/server/src/Http/Resources/v1/ServiceQuote.php +57 -0
- package/server/src/Http/Resources/v1/ServiceRate.php +94 -0
- package/server/src/Http/Resources/v1/ServiceRateFee.php +58 -0
- package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +48 -0
- package/server/src/Http/Resources/v1/TrackingNumber.php +62 -0
- package/server/src/Http/Resources/v1/TrackingStatus.php +84 -0
- package/server/src/Http/Resources/v1/Vehicle.php +75 -0
- package/server/src/Http/Resources/v1/VehicleDevice.php +44 -0
- package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +72 -0
- package/server/src/Http/Resources/v1/Vendor.php +72 -0
- package/server/src/Http/Resources/v1/Zone.php +60 -0
- package/server/src/Imports/OrdersImport.php +18 -0
- package/server/src/Integrations/Lalamove/Lalamove.php +678 -0
- package/server/src/Integrations/Lalamove/LalamoveDeliveryStop.php +97 -0
- package/server/src/Integrations/Lalamove/LalamoveMarket.php +123 -0
- package/server/src/Integrations/Lalamove/LalamoveServiceType.php +161 -0
- package/server/src/Jobs/SimulateDrivingRoute.php +81 -0
- package/server/src/Jobs/SimulateWaypointReached.php +79 -0
- package/server/src/Listeners/HandleOrderCanceled.php +46 -0
- package/server/src/Listeners/HandleOrderCreated.php +23 -0
- package/server/src/Listeners/HandleOrderDispatchFailed.php +35 -0
- package/server/src/Listeners/HandleOrderDispatched.php +108 -0
- package/server/src/Listeners/HandleOrderDriverAssigned.php +42 -0
- package/server/src/Listeners/HandleOrderReady.php +27 -0
- package/server/src/Listeners/HandleUserRemovedFromCompany.php +31 -0
- package/server/src/Models/Contact.php +239 -0
- package/server/src/Models/Driver.php +543 -0
- package/server/src/Models/Entity.php +416 -0
- package/server/src/Models/Fleet.php +203 -0
- package/server/src/Models/FleetDriver.php +73 -0
- package/server/src/Models/FleetVehicle.php +73 -0
- package/server/src/Models/FuelReport.php +125 -0
- package/server/src/Models/IntegratedVendor.php +219 -0
- package/server/src/Models/Issue.php +111 -0
- package/server/src/Models/Order.php +1132 -0
- package/server/src/Models/Payload.php +699 -0
- package/server/src/Models/Place.php +656 -0
- package/server/src/Models/Position.php +119 -0
- package/server/src/Models/Proof.php +94 -0
- package/server/src/Models/PurchaseRate.php +208 -0
- package/server/src/Models/Route.php +128 -0
- package/server/src/Models/ServiceArea.php +161 -0
- package/server/src/Models/ServiceQuote.php +207 -0
- package/server/src/Models/ServiceQuoteItem.php +46 -0
- package/server/src/Models/ServiceRate.php +953 -0
- package/server/src/Models/ServiceRateFee.php +96 -0
- package/server/src/Models/ServiceRateParcelFee.php +116 -0
- package/server/src/Models/TrackingNumber.php +310 -0
- package/server/src/Models/TrackingStatus.php +177 -0
- package/server/src/Models/Vehicle.php +452 -0
- package/server/src/Models/VehicleDevice.php +79 -0
- package/server/src/Models/Vendor.php +244 -0
- package/server/src/Models/Waypoint.php +226 -0
- package/server/src/Models/Zone.php +95 -0
- package/server/src/Notifications/OrderAssigned.php +140 -0
- package/server/src/Notifications/OrderCanceled.php +129 -0
- package/server/src/Notifications/OrderDispatchFailed.php +81 -0
- package/server/src/Notifications/OrderDispatched.php +173 -0
- package/server/src/Notifications/OrderPing.php +162 -0
- package/server/src/Notifications/OrderSplit.php +56 -0
- package/server/src/Observers/DriverObserver.php +34 -0
- package/server/src/Observers/OrderObserver.php +34 -0
- package/server/src/Observers/PayloadObserver.php +30 -0
- package/server/src/Observers/PlaceObserver.php +26 -0
- package/server/src/Observers/PurchaseRateObserver.php +61 -0
- package/server/src/Observers/ServiceAreaObserver.php +35 -0
- package/server/src/Observers/ServiceRateObserver.php +78 -0
- package/server/src/Observers/TrackingNumberObserver.php +44 -0
- package/server/src/Observers/UserObserver.php +20 -0
- package/server/src/Observers/VehicleObserver.php +66 -0
- package/server/src/Providers/EventServiceProvider.php +30 -0
- package/server/src/Providers/FleetOpsServiceProvider.php +94 -0
- package/server/src/Rules/ResolvablePoint.php +37 -0
- package/server/src/Scopes/DriverScope.php +21 -0
- package/server/src/Support/Algo.php +55 -0
- package/server/src/Support/DistanceMatrix.php +27 -0
- package/server/src/Support/Encoding/Polyline.php +168 -0
- package/server/src/Support/Flow.php +622 -0
- package/server/src/Support/Geocoding.php +216 -0
- package/server/src/Support/IntegratedVendors.php +287 -0
- package/server/src/Support/Metrics.php +305 -0
- package/server/src/Support/OSRM.php +191 -0
- package/server/src/Support/ParsePhone.php +21 -0
- package/server/src/Support/Utils.php +1145 -0
- package/server/src/Traits/HasTrackingNumber.php +185 -0
- package/server/src/routes.php +381 -0
- package/server/tests/Feature.php +5 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
8
|
+
|
|
9
|
+
class FuelReport extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Transform the resource into an array.
|
|
13
|
+
*
|
|
14
|
+
* @param \Illuminate\Http\Request $request
|
|
15
|
+
*
|
|
16
|
+
* @return array
|
|
17
|
+
*/
|
|
18
|
+
public function toArray($request)
|
|
19
|
+
{
|
|
20
|
+
return array_merge(
|
|
21
|
+
$this->getInternalIds(),
|
|
22
|
+
[
|
|
23
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
24
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
25
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
26
|
+
'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
|
|
27
|
+
'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
|
|
28
|
+
'driver_name' => $this->when(Http::isInternalRequest(), $this->driver_name),
|
|
29
|
+
'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
|
|
30
|
+
'vehicle' => $this->whenLoaded('vehicle', new Vehicle($this->vehicle)),
|
|
31
|
+
'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
|
|
32
|
+
'odometer' => $this->odometer,
|
|
33
|
+
'amount' => $this->amount,
|
|
34
|
+
'currency' => $this->currency,
|
|
35
|
+
'volume' => $this->volume,
|
|
36
|
+
'metric_unit' => $this->metric_unit,
|
|
37
|
+
'type' => $this->type,
|
|
38
|
+
'location' => $this->location ?? new Point(0, 0),
|
|
39
|
+
'updated_at' => $this->updated_at,
|
|
40
|
+
'created_at' => $this->created_at,
|
|
41
|
+
]
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Transform the resource into an webhook payload.
|
|
47
|
+
*
|
|
48
|
+
* @return array
|
|
49
|
+
*/
|
|
50
|
+
public function toWebhookPayload()
|
|
51
|
+
{
|
|
52
|
+
return [
|
|
53
|
+
'id' => $this->public_id,
|
|
54
|
+
'driver' => data_get($this, 'driver.public_id'),
|
|
55
|
+
'vehicle' => data_get($this, 'vehicle.public_id'),
|
|
56
|
+
'odometer' => $this->odometer,
|
|
57
|
+
'amount' => $this->amount,
|
|
58
|
+
'currency' => $this->currency,
|
|
59
|
+
'volume' => $this->volume,
|
|
60
|
+
'metric_unit' => $this->metric_unit,
|
|
61
|
+
'type' => $this->type,
|
|
62
|
+
'location' => $this->location ?? new Point(0, 0),
|
|
63
|
+
'updated_at' => $this->updated_at,
|
|
64
|
+
'created_at' => $this->created_at,
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Order extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Transform the resource into an array.
|
|
14
|
+
*
|
|
15
|
+
* @param \Illuminate\Http\Request $request
|
|
16
|
+
*
|
|
17
|
+
* @return array
|
|
18
|
+
*/
|
|
19
|
+
public function toArray($request)
|
|
20
|
+
{
|
|
21
|
+
return [
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
|
+
'internal_id' => $this->internal_id,
|
|
26
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
27
|
+
'transaction_uuid' => $this->when(Http::isInternalRequest(), $this->transaction_uuid),
|
|
28
|
+
'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
|
|
29
|
+
'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
|
|
30
|
+
'facilitator_uuid' => $this->when(Http::isInternalRequest(), $this->facilitator_uuid),
|
|
31
|
+
'facilitator_type' => $this->when(Http::isInternalRequest(), $this->facilitator_type),
|
|
32
|
+
'payload_uuid' => $this->when(Http::isInternalRequest(), $this->payload_uuid),
|
|
33
|
+
'route_uuid' => $this->when(Http::isInternalRequest(), $this->route_uuid),
|
|
34
|
+
'purchase_rate_uuid' => $this->when(Http::isInternalRequest(), $this->purchase_rate_uuid),
|
|
35
|
+
'tracking_number_uuid' => $this->when(Http::isInternalRequest(), $this->tracking_number_uuid),
|
|
36
|
+
'driver_assigned_uuid' => $this->when(Http::isInternalRequest(), $this->driver_assigned_uuid),
|
|
37
|
+
'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
|
|
38
|
+
'has_driver_assigned' => $this->when(Http::isInternalRequest(), $this->has_driver_assigned),
|
|
39
|
+
'is_scheduled' => $this->when(Http::isInternalRequest(), $this->is_scheduled),
|
|
40
|
+
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
41
|
+
'payload' => new Payload($this->payload),
|
|
42
|
+
'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
|
|
43
|
+
'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob', 'driverAssigned'])->first()),
|
|
44
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
45
|
+
'tracking_statuses' => $this->whenLoaded('trackingStatuses', TrackingStatus::collection($this->trackingStatuses)),
|
|
46
|
+
'purchase_rate' => new PurchaseRate($this->purchaseRate),
|
|
47
|
+
'notes' => $this->notes,
|
|
48
|
+
'type' => $this->type,
|
|
49
|
+
'status' => $this->status,
|
|
50
|
+
'pod_method' => $this->pod_method,
|
|
51
|
+
'pod_required' => $this->pod_required ?? false,
|
|
52
|
+
'adhoc' => $this->adhoc,
|
|
53
|
+
'adhoc_distance' => (int) $this->getAdhocDistance(),
|
|
54
|
+
'distance' => (int) $this->distance,
|
|
55
|
+
'time' => (int) $this->time,
|
|
56
|
+
'meta' => $this->meta ?? [],
|
|
57
|
+
'dispatched_at' => $this->dispatched_at,
|
|
58
|
+
'started_at' => $this->started_at,
|
|
59
|
+
'scheduled_at' => $this->scheduled_at,
|
|
60
|
+
'updated_at' => $this->updated_at,
|
|
61
|
+
'created_at' => $this->created_at,
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Set the customer type for the given data array.
|
|
67
|
+
*
|
|
68
|
+
* @param array $resolved the input data array
|
|
69
|
+
*
|
|
70
|
+
* @return array the modified data array with the customer type set
|
|
71
|
+
*/
|
|
72
|
+
public function setCustomerType($resolved)
|
|
73
|
+
{
|
|
74
|
+
if (empty($resolved)) {
|
|
75
|
+
return $resolved;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
data_set($resolved, 'type', 'customer');
|
|
79
|
+
data_set($resolved, 'customer_type', 'customer-' . Utils::toEmberResourceType($this->customer_type));
|
|
80
|
+
|
|
81
|
+
return $resolved;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Set the facilitator type for the given data array.
|
|
86
|
+
*
|
|
87
|
+
* @param array $resolved the input data array
|
|
88
|
+
*
|
|
89
|
+
* @return array the modified data array with the facilitator type set
|
|
90
|
+
*/
|
|
91
|
+
public function setFacilitatorType($resolved)
|
|
92
|
+
{
|
|
93
|
+
if (empty($resolved)) {
|
|
94
|
+
return $resolved;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
data_set($resolved, 'type', 'facilitator');
|
|
98
|
+
data_set($resolved, 'facilitator_type', 'facilitator-' . Utils::toEmberResourceType($this->facilitator_type));
|
|
99
|
+
|
|
100
|
+
return $resolved;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Transform the resource into an webhook payload.
|
|
105
|
+
*
|
|
106
|
+
* @return array
|
|
107
|
+
*/
|
|
108
|
+
public function toWebhookPayload()
|
|
109
|
+
{
|
|
110
|
+
return [
|
|
111
|
+
'id' => $this->public_id,
|
|
112
|
+
'internal_id' => $this->internal_id,
|
|
113
|
+
'customer' => Resolve::resourceForMorph($this->customer_type, $this->customer_uuid),
|
|
114
|
+
'payload' => new Payload($this->payload),
|
|
115
|
+
'facilitator' => Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid),
|
|
116
|
+
'driver_assigned' => new Driver($this->driverAssigned),
|
|
117
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
118
|
+
'purchase_rate' => new PurchaseRate($this->purchaseRate),
|
|
119
|
+
'notes' => $this->notes ?? '',
|
|
120
|
+
'type' => $this->type ?? null,
|
|
121
|
+
'status' => $this->status,
|
|
122
|
+
'adhoc' => $this->adhoc,
|
|
123
|
+
'meta' => $this->meta ?? [],
|
|
124
|
+
'dispatched_at' => $this->dispatched_at,
|
|
125
|
+
'started_at' => $this->started_at,
|
|
126
|
+
'scheduled_at' => $this->scheduled_at,
|
|
127
|
+
'updated_at' => $this->updated_at,
|
|
128
|
+
'created_at' => $this->created_at,
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
|
|
9
|
+
class Payload extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Transform the resource into an array.
|
|
13
|
+
*
|
|
14
|
+
* @param \Illuminate\Http\Request $request
|
|
15
|
+
*
|
|
16
|
+
* @return array
|
|
17
|
+
*/
|
|
18
|
+
public function toArray($request)
|
|
19
|
+
{
|
|
20
|
+
return array_merge(
|
|
21
|
+
$this->getInternalIds(),
|
|
22
|
+
[
|
|
23
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
24
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
25
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
26
|
+
'current_waypoint_uuid' => $this->when(Http::isInternalRequest(), $this->current_waypoint_uuid),
|
|
27
|
+
'pickup_uuid' => $this->when(Http::isInternalRequest(), $this->pickup_uuid),
|
|
28
|
+
'dropoff_uuid' => $this->when(Http::isInternalRequest(), $this->dropoff_uuid),
|
|
29
|
+
'return_uuid' => $this->when(Http::isInternalRequest(), $this->return_uuid),
|
|
30
|
+
'current_waypoint' => $this->when(!Http::isInternalRequest() && $this->currentWaypoint, data_get($this, 'currentWaypoint.public_id'), null),
|
|
31
|
+
'pickup' => new Place($this->pickup),
|
|
32
|
+
'dropoff' => new Place($this->dropoff),
|
|
33
|
+
'return' => new Place($this->return),
|
|
34
|
+
'waypoints' => $this->waypoints($this->waypoints),
|
|
35
|
+
'entities' => Entity::collection($this->entities ?? []),
|
|
36
|
+
'cod_amount' => $this->cod_amount ?? null,
|
|
37
|
+
'cod_currency' => $this->cod_currency ?? null,
|
|
38
|
+
'cod_payment_method' => $this->cod_payment_method ?? null,
|
|
39
|
+
'meta' => $this->meta ?? [],
|
|
40
|
+
'updated_at' => $this->updated_at,
|
|
41
|
+
'created_at' => $this->created_at,
|
|
42
|
+
]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Transform the resource into an webhook payload.
|
|
48
|
+
*
|
|
49
|
+
* @return array
|
|
50
|
+
*/
|
|
51
|
+
public function toWebhookPayload()
|
|
52
|
+
{
|
|
53
|
+
return [
|
|
54
|
+
'id' => $this->public_id,
|
|
55
|
+
'pickup' => new Place($this->pickup),
|
|
56
|
+
'dropoff' => new Place($this->dropoff),
|
|
57
|
+
'return' => new Place($this->return),
|
|
58
|
+
'waypoints' => static::waypoints($this->waypoints),
|
|
59
|
+
'entities' => Entity::collection($this->entities ?? []),
|
|
60
|
+
'cod_amount' => $this->cod_amount ?? null,
|
|
61
|
+
'cod_currency' => $this->cod_currency ?? null,
|
|
62
|
+
'cod_payment_method' => $this->cod_payment_method ?? null,
|
|
63
|
+
'meta' => $this->meta ?? [],
|
|
64
|
+
'updated_at' => $this->updated_at,
|
|
65
|
+
'created_at' => $this->created_at,
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the correct pickup resource if applicable.
|
|
71
|
+
*
|
|
72
|
+
* @param \Illuminate\Support\Collection $waypoints
|
|
73
|
+
*
|
|
74
|
+
* @return Illuminate\Http\Resources\Json\JsonResource|null
|
|
75
|
+
*/
|
|
76
|
+
public function waypoints($waypoints)
|
|
77
|
+
{
|
|
78
|
+
if (empty($waypoints)) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$waypoints = $waypoints->map(
|
|
83
|
+
function ($place) {
|
|
84
|
+
$waypoint = Waypoint::where(['payload_uuid' => $this->uuid, 'place_uuid' => $place->uuid])->without(['place'])->with(['trackingNumber'])->first();
|
|
85
|
+
$place->tracking_number = new TrackingNumber($waypoint->trackingNumber);
|
|
86
|
+
$place->order = $waypoint->order;
|
|
87
|
+
|
|
88
|
+
return $place;
|
|
89
|
+
}
|
|
90
|
+
)->sortBy('order');
|
|
91
|
+
|
|
92
|
+
return Place::collection($waypoints ?? []);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Fleetbase\Support\Resolve;
|
|
8
|
+
use Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
9
|
+
|
|
10
|
+
class Place extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Transform the resource into an array.
|
|
14
|
+
*
|
|
15
|
+
* @param \Illuminate\Http\Request $request
|
|
16
|
+
*
|
|
17
|
+
* @return array
|
|
18
|
+
*/
|
|
19
|
+
public function toArray($request)
|
|
20
|
+
{
|
|
21
|
+
return array_merge(
|
|
22
|
+
$this->getInternalIds(),
|
|
23
|
+
[
|
|
24
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
25
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
26
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
27
|
+
'name' => $this->name,
|
|
28
|
+
'location' => $this->location ?? new Point(0, 0),
|
|
29
|
+
'address' => $this->address,
|
|
30
|
+
'address_html' => $this->when(Http::isInternalRequest(), $this->address_html),
|
|
31
|
+
'street1' => $this->street1 ?? null,
|
|
32
|
+
'street2' => $this->street2 ?? null,
|
|
33
|
+
'city' => $this->city ?? null,
|
|
34
|
+
'province' => $this->province ?? null,
|
|
35
|
+
'postal_code' => $this->postal_code ?? null,
|
|
36
|
+
'neighborhood' => $this->neighborhood ?? null,
|
|
37
|
+
'district' => $this->district ?? null,
|
|
38
|
+
'building' => $this->building ?? null,
|
|
39
|
+
'security_access_code' => $this->security_access_code ?? null,
|
|
40
|
+
'country' => $this->country ?? null,
|
|
41
|
+
'country_name' => $this->when(Http::isInternalRequest(), $this->country_name),
|
|
42
|
+
'phone' => $this->phone ?? null,
|
|
43
|
+
'owner' => $this->when(!Http::isInternalRequest(), Resolve::resourceForMorph($this->owner_type, $this->owner_uuid)),
|
|
44
|
+
'tracking_number' => $this->whenLoaded('trackingNumber', $this->trackingNumber),
|
|
45
|
+
'type' => $this->type ?? null,
|
|
46
|
+
'meta' => $this->meta ?? [],
|
|
47
|
+
'updated_at' => $this->updated_at,
|
|
48
|
+
'created_at' => $this->created_at,
|
|
49
|
+
]
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Transform the resource into an webhook payload.
|
|
55
|
+
*
|
|
56
|
+
* @return array
|
|
57
|
+
*/
|
|
58
|
+
public function toWebhookPayload()
|
|
59
|
+
{
|
|
60
|
+
return [
|
|
61
|
+
'id' => $this->public_id,
|
|
62
|
+
'internal_id' => $this->internal_id,
|
|
63
|
+
'name' => $this->name,
|
|
64
|
+
'latitude' => $this->latitude ?? null,
|
|
65
|
+
'longitude' => $this->longitude ?? null,
|
|
66
|
+
'street1' => $this->street1 ?? null,
|
|
67
|
+
'street2' => $this->street2 ?? null,
|
|
68
|
+
'city' => $this->city ?? null,
|
|
69
|
+
'province' => $this->province ?? null,
|
|
70
|
+
'postal_code' => $this->postal_code ?? null,
|
|
71
|
+
'neighborhood' => $this->neighborhood ?? null,
|
|
72
|
+
'district' => $this->district ?? null,
|
|
73
|
+
'building' => $this->building ?? null,
|
|
74
|
+
'security_access_code' => $this->security_access_code ?? null,
|
|
75
|
+
'country' => $this->country ?? null,
|
|
76
|
+
'phone' => $this->phone ?? null,
|
|
77
|
+
'owner' => Resolve::resourceForMorph($this->owner_type, $this->owner_uuid),
|
|
78
|
+
'type' => $this->type ?? null,
|
|
79
|
+
'meta' => $this->meta ?? [],
|
|
80
|
+
'updated_at' => $this->updated_at,
|
|
81
|
+
'created_at' => $this->created_at,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class Proof extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
*
|
|
15
|
+
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return array_merge(
|
|
20
|
+
$this->getInternalIds(),
|
|
21
|
+
[
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
|
+
'subject_id' => $this->subject ? $this->subject->public_id : null,
|
|
26
|
+
'order_id' => $this->order ? $this->order->public_id : null,
|
|
27
|
+
'url' => $this->file_url,
|
|
28
|
+
'remarks' => $this->remarks,
|
|
29
|
+
'raw' => $this->raw_data,
|
|
30
|
+
'data' => $this->data,
|
|
31
|
+
'updated_at' => $this->updated_at,
|
|
32
|
+
'created_at' => $this->created_at,
|
|
33
|
+
]
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
|
|
9
|
+
class PurchaseRate extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Transform the resource into an array.
|
|
13
|
+
*
|
|
14
|
+
* @param \Illuminate\Http\Request $request
|
|
15
|
+
*
|
|
16
|
+
* @return array
|
|
17
|
+
*/
|
|
18
|
+
public function toArray($request)
|
|
19
|
+
{
|
|
20
|
+
return array_merge(
|
|
21
|
+
$this->getInternalIds(),
|
|
22
|
+
[
|
|
23
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
24
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
25
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
26
|
+
'service_quote' => $this->service_quote_id,
|
|
27
|
+
'order' => $this->order_id,
|
|
28
|
+
'customer' => $this->customer_id,
|
|
29
|
+
'transaction' => $this->transaction_id,
|
|
30
|
+
'amount' => $this->amount,
|
|
31
|
+
'currency' => $this->currency,
|
|
32
|
+
'status' => $this->status,
|
|
33
|
+
'updated_at' => $this->updated_at,
|
|
34
|
+
'created_at' => $this->created_at,
|
|
35
|
+
]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Transform the resource into an webhook payload.
|
|
41
|
+
*
|
|
42
|
+
* @return array
|
|
43
|
+
*/
|
|
44
|
+
public function toWebhookPayload()
|
|
45
|
+
{
|
|
46
|
+
return [
|
|
47
|
+
'id' => $this->public_id,
|
|
48
|
+
'service_quote' => $this->service_quote_id,
|
|
49
|
+
'order' => $this->order_id,
|
|
50
|
+
'customer' => $this->customer_id,
|
|
51
|
+
'transaction' => $this->transaction_id,
|
|
52
|
+
'amount' => $this->amount,
|
|
53
|
+
'currency' => $this->currency,
|
|
54
|
+
'status' => $this->status,
|
|
55
|
+
'updated_at' => $this->updated_at,
|
|
56
|
+
'created_at' => $this->created_at,
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the correct service_quote resource if applicable.
|
|
62
|
+
*
|
|
63
|
+
* @return Illuminate\Http\Resources\Json\JsonResource|null
|
|
64
|
+
*/
|
|
65
|
+
public function serviceQuote()
|
|
66
|
+
{
|
|
67
|
+
if (Utils::notEmpty($this->service_quote_uuid) && Utils::isEmpty($this->serviceQuote)) {
|
|
68
|
+
$this->load(['serviceArea']);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (Utils::isEmpty($this->serviceQuote)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new ServiceQuote($this->serviceQuote);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class ServiceArea extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
*
|
|
15
|
+
* @return array
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return array_merge(
|
|
20
|
+
$this->getInternalIds(),
|
|
21
|
+
[
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
|
+
'name' => $this->name,
|
|
26
|
+
'type' => $this->type,
|
|
27
|
+
'location' => $this->location,
|
|
28
|
+
'border' => $this->border,
|
|
29
|
+
'zones' => $this->whenLoaded('zones', Zone::collection($this->zones)),
|
|
30
|
+
'status' => $this->status,
|
|
31
|
+
'updated_at' => $this->updated_at,
|
|
32
|
+
'created_at' => $this->created_at,
|
|
33
|
+
]
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Transform the resource into an webhook payload.
|
|
39
|
+
*
|
|
40
|
+
* @return array
|
|
41
|
+
*/
|
|
42
|
+
public function toWebhookPayload()
|
|
43
|
+
{
|
|
44
|
+
return [
|
|
45
|
+
'id' => $this->public_id,
|
|
46
|
+
'name' => $this->name,
|
|
47
|
+
'type' => $this->type,
|
|
48
|
+
'location' => $this->location,
|
|
49
|
+
'border' => $this->border,
|
|
50
|
+
'status' => $this->status,
|
|
51
|
+
'updated_at' => $this->updated_at,
|
|
52
|
+
'created_at' => $this->created_at,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class ServiceQuote extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
*
|
|
15
|
+
* @return array
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return array_merge(
|
|
20
|
+
$this->getInternalIds(),
|
|
21
|
+
[
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
|
+
'service_rate_uuid' => $this->when(Http::isInternalRequest(), $this->service_rate_uuid),
|
|
26
|
+
'payload_uuid' => $this->when(Http::isInternalRequest(), $this->payload_uuid),
|
|
27
|
+
'service_rate_name' => $this->when(Http::isInternalRequest(), data_get($this, 'serviceRate.name')),
|
|
28
|
+
'service_rate' => $this->when(Http::isPublicRequest(), data_get($this, 'serviceRate.public_id')),
|
|
29
|
+
'facilitator' => $this->when(Http::isPublicRequest(), data_get($this, 'integratedVendor.public_id')),
|
|
30
|
+
'request_id' => $this->request_id,
|
|
31
|
+
'amount' => $this->amount,
|
|
32
|
+
'currency' => $this->currency,
|
|
33
|
+
'updated_at' => $this->updated_at,
|
|
34
|
+
'created_at' => $this->created_at,
|
|
35
|
+
]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Transform the resource into an webhook payload.
|
|
41
|
+
*
|
|
42
|
+
* @return array
|
|
43
|
+
*/
|
|
44
|
+
public function toWebhookPayload()
|
|
45
|
+
{
|
|
46
|
+
return [
|
|
47
|
+
'id' => $this->public_id,
|
|
48
|
+
'service_rate' => data_get($this, 'serviceRate.public_id'),
|
|
49
|
+
'facilitator' => data_get($this, 'integratedVendor.public_id'),
|
|
50
|
+
'request_id' => $this->request_id,
|
|
51
|
+
'amount' => $this->amount,
|
|
52
|
+
'currency' => $this->currency,
|
|
53
|
+
'updated_at' => $this->updated_at,
|
|
54
|
+
'created_at' => $this->created_at,
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
}
|