@fleetbase/fleetops-engine 0.2.6 → 0.2.8
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.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,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
|
|
7
|
+
class UpdateServiceQuoteRequest extends FleetbaseRequest
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Determine if the user is authorized to make this request.
|
|
11
|
+
*
|
|
12
|
+
* @return bool
|
|
13
|
+
*/
|
|
14
|
+
public function authorize()
|
|
15
|
+
{
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the validation rules that apply to the request.
|
|
21
|
+
*
|
|
22
|
+
* @return array
|
|
23
|
+
*/
|
|
24
|
+
public function rules()
|
|
25
|
+
{
|
|
26
|
+
return [
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
|
|
7
|
+
class UpdateServiceRateRequest extends FleetbaseRequest
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Determine if the user is authorized to make this request.
|
|
11
|
+
*
|
|
12
|
+
* @return bool
|
|
13
|
+
*/
|
|
14
|
+
public function authorize()
|
|
15
|
+
{
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the validation rules that apply to the request.
|
|
21
|
+
*
|
|
22
|
+
* @return array
|
|
23
|
+
*/
|
|
24
|
+
public function rules()
|
|
25
|
+
{
|
|
26
|
+
return [
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
|
|
7
|
+
class UpdateTrackingStatusRequest extends FleetbaseRequest
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Determine if the user is authorized to make this request.
|
|
11
|
+
*
|
|
12
|
+
* @return bool
|
|
13
|
+
*/
|
|
14
|
+
public function authorize()
|
|
15
|
+
{
|
|
16
|
+
return request()->session()->has('api_credential');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the validation rules that apply to the request.
|
|
21
|
+
*
|
|
22
|
+
* @return array
|
|
23
|
+
*/
|
|
24
|
+
public function rules()
|
|
25
|
+
{
|
|
26
|
+
return [
|
|
27
|
+
'status' => 'required|string',
|
|
28
|
+
'details' => 'required|string',
|
|
29
|
+
'code' => 'nullable|string',
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\Internal\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
|
|
7
|
+
class IntegratedVendorFacilitator extends FleetbaseResource
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Transform the resource into an array.
|
|
11
|
+
*
|
|
12
|
+
* @param \Illuminate\Http\Request $request
|
|
13
|
+
*
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return array_merge(
|
|
19
|
+
$this->getInternalIds(),
|
|
20
|
+
[
|
|
21
|
+
'id' => $this->public_id,
|
|
22
|
+
'public_id' => $this->public_id,
|
|
23
|
+
'uuid' => $this->uuid,
|
|
24
|
+
'name' => $this->name,
|
|
25
|
+
'photo_url' => $this->photo_url,
|
|
26
|
+
'provider' => $this->provider,
|
|
27
|
+
'options' => $this->options,
|
|
28
|
+
'sandbox' => $this->sandbox,
|
|
29
|
+
'facilitator_type' => $this->type,
|
|
30
|
+
'type' => 'facilitator',
|
|
31
|
+
'status' => $this->status,
|
|
32
|
+
'updated_at' => $this->updated_at,
|
|
33
|
+
'created_at' => $this->created_at,
|
|
34
|
+
]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\Internal\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Http\Resources\v1\VehicleWithoutDriver;
|
|
6
|
+
use Illuminate\Support\Arr;
|
|
7
|
+
|
|
8
|
+
class Vehicle extends VehicleWithoutDriver
|
|
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
|
+
$vehicle = parent::toArray($request);
|
|
20
|
+
$vehicle = Arr::insertAfterKey(
|
|
21
|
+
$vehicle,
|
|
22
|
+
[
|
|
23
|
+
'uuid' => $this->uuid,
|
|
24
|
+
'public_id' => $this->public_id,
|
|
25
|
+
'display_name' => $this->display_name,
|
|
26
|
+
'driver_name' => $this->driver_name,
|
|
27
|
+
],
|
|
28
|
+
'id'
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return $vehicle;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\Internal\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Place;
|
|
6
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
|
7
|
+
|
|
8
|
+
class Waypoint extends JsonResource
|
|
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
|
+
$place = (new Place($this->place))->toArray($request);
|
|
20
|
+
|
|
21
|
+
return array_merge(
|
|
22
|
+
$place,
|
|
23
|
+
[
|
|
24
|
+
'uuid' => $this->place->uuid,
|
|
25
|
+
'waypoint_uuid' => $this->uuid,
|
|
26
|
+
'waypoint_public_id' => $this->public_id,
|
|
27
|
+
'tracking_number_uuid' => $this->tracking_number_uuid,
|
|
28
|
+
'tracking' => $this->tracking,
|
|
29
|
+
'status' => $this->status,
|
|
30
|
+
'status_code' => $this->status_code,
|
|
31
|
+
]
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 Contact 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
|
+
'internal_id' => $this->internal_id,
|
|
26
|
+
'name' => $this->name,
|
|
27
|
+
'title' => $this->title ?? null,
|
|
28
|
+
'email' => $this->email ?? null,
|
|
29
|
+
'phone' => $this->phone ?? null,
|
|
30
|
+
'photo_url' => $this->photo_url ?? null,
|
|
31
|
+
'type' => $this->type ?? null,
|
|
32
|
+
'meta' => $this->meta ?? [],
|
|
33
|
+
'slug' => $this->slug ?? null,
|
|
34
|
+
'updated_at' => $this->updated_at,
|
|
35
|
+
'created_at' => $this->created_at,
|
|
36
|
+
]
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Transform the resource into an webhook payload.
|
|
42
|
+
*
|
|
43
|
+
* @return array
|
|
44
|
+
*/
|
|
45
|
+
public function toWebhookPayload()
|
|
46
|
+
{
|
|
47
|
+
return [
|
|
48
|
+
'id' => $this->public_id,
|
|
49
|
+
'internal_id' => $this->internal_id,
|
|
50
|
+
'name' => $this->name,
|
|
51
|
+
'title' => $this->title ?? null,
|
|
52
|
+
'email' => $this->email ?? null,
|
|
53
|
+
'phone' => $this->phone ?? null,
|
|
54
|
+
'photo_url' => $this->photo_url ?? null,
|
|
55
|
+
'type' => $this->type ?? null,
|
|
56
|
+
'meta' => $this->meta ?? [],
|
|
57
|
+
'slug' => $this->slug ?? null,
|
|
58
|
+
'updated_at' => $this->updated_at,
|
|
59
|
+
'created_at' => $this->created_at,
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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 CurrentJob 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
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
26
|
+
'internal_id' => $this->internal_id,
|
|
27
|
+
'payload' => $this->when(Http::isInternalRequest(), new Payload($this->payload)),
|
|
28
|
+
'type' => $this->type,
|
|
29
|
+
'status' => $this->status,
|
|
30
|
+
'meta' => $this->meta ?? [],
|
|
31
|
+
'updated_at' => $this->updated_at,
|
|
32
|
+
'created_at' => $this->created_at,
|
|
33
|
+
]
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 Illuminate\Support\Arr;
|
|
9
|
+
|
|
10
|
+
class DeletedResource 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
|
+
$deleted = [
|
|
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
|
+
'object' => $this->getObjectType(),
|
|
26
|
+
'time' => $this->deleted_at,
|
|
27
|
+
'deleted' => true,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
if (Http::isInternalRequest()) {
|
|
31
|
+
$deleted = Arr::insertAfterKey($deleted, ['uuid' => $this->uuid, 'public_id' => $this->public_id], 'id');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return $deleted;
|
|
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
|
+
'object' => $this->getObjectType(),
|
|
47
|
+
'time' => $this->deleted_at,
|
|
48
|
+
'deleted' => true,
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get the object type for this resource.
|
|
54
|
+
*
|
|
55
|
+
* @return string
|
|
56
|
+
*/
|
|
57
|
+
public function getObjectType()
|
|
58
|
+
{
|
|
59
|
+
return strtolower(Utils::getClassName($this->resource));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
9
|
+
|
|
10
|
+
class Driver 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
|
+
'internal_id' => $this->internal_id,
|
|
28
|
+
'name' => $this->name,
|
|
29
|
+
'email' => $this->email ?? null,
|
|
30
|
+
'phone' => $this->phone ?? null,
|
|
31
|
+
'drivers_license_number' => $this->drivers_license_number ?? null,
|
|
32
|
+
'photo_url' => $this->photo_url ?? null,
|
|
33
|
+
'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
|
|
34
|
+
'vehicle_avatar' => $this->when(Http::isInternalRequest(), $this->vehicle_avatar),
|
|
35
|
+
'vendor_name' => $this->when(Http::isInternalRequest(), $this->vendor_name),
|
|
36
|
+
'vehicle' => $this->whenLoaded('vehicle', new VehicleWithoutDriver($this->vehicle)),
|
|
37
|
+
'current_job' => $this->whenLoaded('currentJob', new CurrentJob($this->currentJob)),
|
|
38
|
+
'jobs' => $this->whenLoaded('jobs', CurrentJob::collection($this->jobs()->without(['driverAssigned'])->get())),
|
|
39
|
+
'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
|
|
40
|
+
'fleets' => $this->whenLoaded('fleets', Fleet::collection($this->fleets()->without('drivers')->get())),
|
|
41
|
+
'location' => data_get($this, 'location', new Point(0, 0)),
|
|
42
|
+
'heading' => (int) data_get($this, 'heading', 0),
|
|
43
|
+
'altitude' => (int) data_get($this, 'altitude', 0),
|
|
44
|
+
'speed' => (int) data_get($this, 'speed', 0),
|
|
45
|
+
'country' => data_get($this, 'country'),
|
|
46
|
+
'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
|
|
47
|
+
'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
|
|
48
|
+
'online' => data_get($this, 'online', false),
|
|
49
|
+
'status' => $this->status,
|
|
50
|
+
'token' => data_get($this, 'token'),
|
|
51
|
+
'meta' => $this->meta,
|
|
52
|
+
'updated_at' => $this->updated_at,
|
|
53
|
+
'created_at' => $this->created_at,
|
|
54
|
+
]
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Transform the resource into an webhook payload.
|
|
60
|
+
*
|
|
61
|
+
* @return array
|
|
62
|
+
*/
|
|
63
|
+
public function toWebhookPayload()
|
|
64
|
+
{
|
|
65
|
+
return [
|
|
66
|
+
'id' => $this->public_id,
|
|
67
|
+
'internal_id' => $this->internal_id,
|
|
68
|
+
'name' => $this->name,
|
|
69
|
+
'email' => $this->email ?? null,
|
|
70
|
+
'phone' => $this->phone ?? null,
|
|
71
|
+
'photo_url' => $this->photo_url ?? null,
|
|
72
|
+
'vehicle' => $this->vehicle->public_id ?? null,
|
|
73
|
+
'current_job' => $this->currentJob->public_id ?? null,
|
|
74
|
+
'vendor' => $this->vendor->public_id ?? null,
|
|
75
|
+
'location' => $this->location ?? new Point(0, 0),
|
|
76
|
+
'heading' => $this->heading ?? null,
|
|
77
|
+
'altitude' => $this->altitude ?? null,
|
|
78
|
+
'speed' => $this->speed ?? null,
|
|
79
|
+
'country' => $this->country ?? null,
|
|
80
|
+
'currency' => $this->currency ?? null,
|
|
81
|
+
'city' => $this->city ?? null,
|
|
82
|
+
'online' => $this->online ?? false,
|
|
83
|
+
'status' => $this->status,
|
|
84
|
+
'meta' => $this->meta,
|
|
85
|
+
'updated_at' => $this->updated_at,
|
|
86
|
+
'created_at' => $this->created_at,
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
|
|
9
|
+
class Entity 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
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
26
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
27
|
+
'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
|
|
28
|
+
'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
|
|
29
|
+
'internal_id' => $this->internal_id,
|
|
30
|
+
'name' => $this->name,
|
|
31
|
+
'type' => $this->type ?? null,
|
|
32
|
+
'destination' => $this->when(Http::isPublicRequest(), data_get($this, 'destination.public_id'), null),
|
|
33
|
+
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
34
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
35
|
+
'description' => $this->description ?? null,
|
|
36
|
+
'photo_url' => $this->photo_url ?? null,
|
|
37
|
+
'length' => $this->length ?? null,
|
|
38
|
+
'width' => $this->width ?? null,
|
|
39
|
+
'height' => $this->height ?? null,
|
|
40
|
+
'dimensions_unit' => $this->dimensions_unit ?? null,
|
|
41
|
+
'weight' => $this->weight ?? null,
|
|
42
|
+
'weight_unit' => $this->weight_unit ?? null,
|
|
43
|
+
'declared_value' => $this->declared_value ?? null,
|
|
44
|
+
'price' => $this->price ?? null,
|
|
45
|
+
'sale_price' => $this->sale_price ?? null,
|
|
46
|
+
'sku' => $this->sku ?? null,
|
|
47
|
+
'currency' => $this->currency ?? null,
|
|
48
|
+
'meta' => $this->meta ?? [],
|
|
49
|
+
'updated_at' => $this->updated_at,
|
|
50
|
+
'created_at' => $this->created_at,
|
|
51
|
+
]
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Set the customer type for the given data array.
|
|
57
|
+
*
|
|
58
|
+
* @param array $resolved the input data array
|
|
59
|
+
*
|
|
60
|
+
* @return array the modified data array with the customer type set
|
|
61
|
+
*/
|
|
62
|
+
public function setCustomerType($resolved)
|
|
63
|
+
{
|
|
64
|
+
if (empty($resolved)) {
|
|
65
|
+
return $resolved;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
data_set($resolved, 'type', 'customer');
|
|
69
|
+
data_set($resolved, 'customer_type', Utils::toEmberResourceType($this->customer_type));
|
|
70
|
+
|
|
71
|
+
return $resolved;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Transform the resource into an webhook payload.
|
|
76
|
+
*
|
|
77
|
+
* @return array
|
|
78
|
+
*/
|
|
79
|
+
public function toWebhookPayload()
|
|
80
|
+
{
|
|
81
|
+
return [
|
|
82
|
+
'id' => $this->public_id,
|
|
83
|
+
'internal_id' => $this->internal_id,
|
|
84
|
+
'name' => $this->name,
|
|
85
|
+
'type' => $this->type ?? null,
|
|
86
|
+
'destination' => $this->destination ? $this->destination->public_id : null,
|
|
87
|
+
'customer' => Resolve::resourceForMorph($this->customer_type, $this->customer_uuid),
|
|
88
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
89
|
+
'description' => $this->description ?? null,
|
|
90
|
+
'photo_url' => $this->photo_url ?? null,
|
|
91
|
+
'length' => $this->length ?? null,
|
|
92
|
+
'width' => $this->width ?? null,
|
|
93
|
+
'height' => $this->height ?? null,
|
|
94
|
+
'dimensions_unit' => $this->dimensions_unit ?? null,
|
|
95
|
+
'weight' => $this->weight ?? null,
|
|
96
|
+
'weight_unit' => $this->weight_unit ?? null,
|
|
97
|
+
'declared_value' => $this->declared_value ?? null,
|
|
98
|
+
'price' => $this->price ?? null,
|
|
99
|
+
'sale_price' => $this->sale_price ?? null,
|
|
100
|
+
'sku' => $this->sku ?? null,
|
|
101
|
+
'currency' => $this->currency ?? null,
|
|
102
|
+
'meta' => $this->meta ?? [],
|
|
103
|
+
'updated_at' => $this->updated_at,
|
|
104
|
+
'created_at' => $this->created_at,
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 Fleet 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
|
+
'task' => $this->task ?? null,
|
|
27
|
+
'status' => $this->status ?? null,
|
|
28
|
+
'drivers_count' => $this->when(Http::isInternalRequest(), $this->drivers_count),
|
|
29
|
+
'drivers_online_count' => $this->when(Http::isInternalRequest(), $this->drivers_online_count),
|
|
30
|
+
'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
|
|
31
|
+
'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
|
|
32
|
+
'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
|
|
33
|
+
'parentFleet' => $this->whenLoaded('parent_fleet', new self($this->parent_fleet)),
|
|
34
|
+
'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
|
|
35
|
+
'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
|
|
36
|
+
'updated_at' => $this->updated_at,
|
|
37
|
+
'created_at' => $this->created_at,
|
|
38
|
+
]
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Transform the resource into an webhook payload.
|
|
44
|
+
*
|
|
45
|
+
* @return array
|
|
46
|
+
*/
|
|
47
|
+
public function toWebhookPayload()
|
|
48
|
+
{
|
|
49
|
+
return [
|
|
50
|
+
'id' => $this->public_id,
|
|
51
|
+
'name' => $this->name,
|
|
52
|
+
'task' => $this->task ?? null,
|
|
53
|
+
'status' => $this->status ?? null,
|
|
54
|
+
'service_area' => $this->when($this->serviceArea, data_get($this, 'serviceArea.public_id')),
|
|
55
|
+
'zone' => $this->when($this->zone, data_get($this, 'zone.public_id')),
|
|
56
|
+
'updated_at' => $this->updated_at,
|
|
57
|
+
'created_at' => $this->created_at,
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
}
|