@fleetbase/fleetops-engine 0.3.1 → 0.3.3
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/addon/components/admin/visibility-controls.js +1 -0
- package/addon/components/contact-form-panel.hbs +82 -0
- package/addon/components/contact-form-panel.js +195 -0
- package/addon/components/contact-panel/details.hbs +36 -0
- package/addon/components/contact-panel/details.js +3 -0
- package/addon/components/contact-panel.hbs +52 -0
- package/addon/components/contact-panel.js +161 -0
- package/addon/components/driver-form-panel.hbs +39 -55
- package/addon/components/driver-form-panel.js +41 -0
- package/addon/components/driver-panel/details.hbs +2 -2
- package/addon/components/driver-panel.hbs +12 -10
- package/addon/components/driver-panel.js +13 -0
- package/addon/components/fleet-form-panel.hbs +28 -28
- package/addon/components/fleet-form-panel.js +150 -1
- package/addon/components/fleet-listing-panel.hbs +8 -0
- package/addon/components/fleet-listing-panel.js +34 -0
- package/addon/components/fleet-panel/details.hbs +30 -0
- package/addon/components/fleet-panel/driver-listing.hbs +72 -0
- package/addon/components/fleet-panel/driver-listing.js +149 -0
- package/addon/components/fleet-panel/vehicle-listing.hbs +72 -0
- package/addon/components/fleet-panel/vehicle-listing.js +149 -0
- package/addon/components/fleet-panel.hbs +12 -58
- package/addon/components/fleet-panel.js +148 -26
- package/addon/components/fleet-vehicle-listing.hbs +0 -1
- package/addon/components/fuel-report-form-panel.hbs +41 -0
- package/addon/components/fuel-report-form-panel.js +122 -0
- package/addon/components/fuel-report-panel/details.hbs +38 -0
- package/addon/components/fuel-report-panel.hbs +30 -0
- package/addon/components/fuel-report-panel.js +161 -0
- package/addon/components/issue-form-panel.hbs +85 -0
- package/addon/components/issue-form-panel.js +211 -0
- package/addon/components/issue-panel/details.hbs +48 -0
- package/addon/components/issue-panel.hbs +30 -0
- package/addon/components/issue-panel.js +160 -0
- package/addon/components/layout/fleet-ops-sidebar.hbs +2 -2
- package/addon/components/layout/fleet-ops-sidebar.js +2 -1
- package/addon/components/live-map-drawer/driver-listing.hbs +6 -0
- package/addon/components/live-map-drawer/driver-listing.js +240 -0
- package/addon/components/live-map-drawer/place-listing.hbs +6 -0
- package/addon/components/live-map-drawer/place-listing.js +204 -0
- package/addon/components/live-map-drawer/vehicle-listing.hbs +6 -0
- package/addon/components/live-map-drawer/vehicle-listing.js +216 -0
- package/addon/components/live-map-drawer.hbs +17 -0
- package/addon/components/live-map-drawer.js +104 -0
- package/addon/components/live-map.hbs +5 -1
- package/addon/components/live-map.js +109 -15
- package/addon/components/map-container/toolbar.hbs +15 -9
- package/addon/components/map-container/topbar.hbs +1 -1
- package/addon/components/modals/issue-details.hbs +38 -0
- package/addon/components/modals/issue-from.hbs +138 -0
- package/addon/components/modals/order-event.hbs +1 -1
- package/addon/components/order/schedule-card.hbs +4 -4
- package/addon/components/order/schedule-card.js +13 -6
- package/addon/components/place-form-panel.hbs +50 -0
- package/addon/components/place-form-panel.js +134 -0
- package/addon/components/place-panel/details.hbs +95 -0
- package/addon/components/place-panel.hbs +30 -0
- package/addon/components/place-panel.js +161 -0
- package/addon/components/vehicle-form-panel.hbs +35 -44
- package/addon/components/vehicle-form-panel.js +41 -0
- package/addon/components/vehicle-panel/details.hbs +8 -2
- package/addon/components/vehicle-panel.hbs +8 -6
- package/addon/components/vendor-form-panel/create-form.hbs +114 -0
- package/addon/components/vendor-form-panel/create-form.js +158 -0
- package/addon/components/vendor-form-panel/edit-form.hbs +98 -0
- package/addon/components/vendor-form-panel/edit-form.js +51 -0
- package/addon/components/vendor-form-panel.hbs +48 -0
- package/addon/components/vendor-form-panel.js +226 -0
- package/addon/components/vendor-panel/details.hbs +77 -0
- package/addon/components/vendor-panel/details.js +12 -0
- package/addon/components/vendor-panel.hbs +58 -0
- package/addon/components/vendor-panel.js +161 -0
- package/addon/controllers/management/contacts/index/details.js +55 -0
- package/addon/controllers/management/contacts/index/edit.js +111 -0
- package/addon/controllers/management/contacts/index/new.js +88 -0
- package/addon/controllers/management/contacts/index.js +23 -128
- package/addon/controllers/management/drivers/index/new.js +2 -2
- package/addon/controllers/management/drivers/index.js +18 -32
- package/addon/controllers/management/fleets/index/details.js +53 -0
- package/addon/controllers/management/fleets/index/edit.js +75 -41
- package/addon/controllers/management/fleets/index/new.js +42 -57
- package/addon/controllers/management/fleets/index.js +0 -1
- package/addon/controllers/management/fuel-reports/index/details.js +63 -0
- package/addon/controllers/management/fuel-reports/index/edit.js +111 -0
- package/addon/controllers/management/fuel-reports/index/new.js +95 -0
- package/addon/controllers/management/fuel-reports/index.js +57 -127
- package/addon/controllers/management/issues/index/details.js +54 -0
- package/addon/controllers/management/issues/index/edit.js +111 -0
- package/addon/controllers/management/issues/index/new.js +94 -0
- package/addon/controllers/management/issues/index.js +131 -26
- package/addon/controllers/management/places/index/details.js +55 -0
- package/addon/controllers/management/places/index/edit.js +111 -0
- package/addon/controllers/management/places/index/new.js +88 -0
- package/addon/controllers/management/places/index.js +21 -182
- package/addon/controllers/management/vehicles/index/new.js +2 -6
- package/addon/controllers/management/vendors/index/details.js +55 -0
- package/addon/controllers/management/vendors/index/edit.js +111 -0
- package/addon/controllers/management/vendors/index/new.js +88 -0
- package/addon/controllers/management/vendors/index.js +43 -247
- package/addon/controllers/operations/orders/index.js +29 -15
- package/addon/controllers/operations/scheduler/index.js +45 -30
- package/addon/routes/management/contacts/index/details.js +14 -0
- package/addon/routes/management/contacts/index/edit.js +10 -0
- package/addon/routes/management/contacts/index/new.js +3 -0
- package/addon/routes/management/contacts/index.js +1 -1
- package/addon/routes/management/fleets/index/details.js +1 -1
- package/addon/routes/management/fleets/index/edit.js +1 -1
- package/addon/routes/management/fleets/index.js +1 -1
- package/addon/routes/management/fuel-reports/index/details.js +14 -0
- package/addon/routes/management/fuel-reports/index/edit.js +10 -0
- package/addon/routes/management/fuel-reports/index/new.js +3 -0
- package/addon/routes/management/fuel-reports/index.js +3 -1
- package/addon/routes/management/issues/index/details.js +14 -0
- package/addon/routes/management/issues/index/edit.js +10 -0
- package/addon/routes/management/issues/index/new.js +3 -0
- package/addon/routes/management/issues/index.js +1 -1
- package/addon/routes/management/places/index/details.js +14 -0
- package/addon/routes/management/places/index/edit.js +10 -0
- package/addon/routes/management/places/index/new.js +3 -0
- package/addon/routes/management/places/index.js +6 -1
- package/addon/routes/management/vendors/index/details.js +15 -0
- package/addon/routes/management/vendors/index/edit.js +11 -0
- package/addon/routes/management/vendors/index/new.js +3 -0
- package/addon/routes/management/vendors/index.js +1 -0
- package/addon/routes/operations/scheduler/index.js +25 -0
- package/addon/routes.js +27 -7
- package/addon/services/context-panel.js +60 -0
- package/addon/styles/fleetops-engine.css +28 -0
- package/addon/templates/management/contacts/index/details.hbs +1 -0
- package/addon/templates/management/contacts/index/edit.hbs +1 -0
- package/addon/templates/management/contacts/index/new.hbs +1 -0
- package/addon/templates/management/contacts/index.hbs +22 -3
- package/addon/templates/management/drivers/index.hbs +29 -5
- package/addon/templates/management/fleets/index/details.hbs +1 -1
- package/addon/templates/management/fleets/index/edit.hbs +1 -1
- package/addon/templates/management/fleets/index/new.hbs +1 -1
- package/addon/templates/management/fuel-reports/index/details.hbs +1 -0
- package/addon/templates/management/fuel-reports/index/edit.hbs +1 -0
- package/addon/templates/management/fuel-reports/index/new.hbs +1 -0
- package/addon/templates/management/fuel-reports/index.hbs +25 -4
- package/addon/templates/management/issues/index/details.hbs +1 -0
- package/addon/templates/management/issues/index/edit.hbs +1 -0
- package/addon/templates/management/issues/index/new.hbs +1 -0
- package/addon/templates/management/issues/index.hbs +5 -3
- package/addon/templates/management/places/index/details.hbs +1 -0
- package/addon/templates/management/places/index/edit.hbs +1 -0
- package/addon/templates/management/places/index/new.hbs +1 -0
- package/addon/templates/management/vendors/index/details.hbs +1 -0
- package/addon/templates/management/vendors/index/edit.hbs +1 -0
- package/addon/templates/management/vendors/index/new.hbs +1 -0
- package/addon/templates/operations/orders/index.hbs +5 -5
- package/addon/templates/operations/scheduler/index.hbs +33 -9
- package/addon/utils/create-full-calendar-event-from-order.js +8 -0
- package/app/components/contact-form-panel.js +1 -0
- package/app/components/contact-panel/details.js +1 -0
- package/app/components/contact-panel.js +1 -0
- package/app/components/{full-calendar/draggable.js → fleet-listing-panel.js} +1 -1
- package/app/components/fleet-panel/details.js +1 -0
- package/app/components/fleet-panel/driver-listing.js +1 -0
- package/app/components/fleet-panel/vehicle-listing.js +1 -0
- package/app/components/fuel-report-form-panel.js +1 -0
- package/app/components/{full-calendar.js → fuel-report-panel.js} +1 -1
- package/app/components/issue-form-panel.js +1 -0
- package/app/components/issue-panel.js +1 -0
- package/app/components/live-map-drawer/driver-listing.js +1 -0
- package/app/components/live-map-drawer/place-listing.js +1 -0
- package/app/components/live-map-drawer/vehicle-listing.js +1 -0
- package/app/components/live-map-drawer.js +1 -0
- package/app/components/place-form-panel.js +1 -0
- package/app/components/place-panel.js +1 -0
- package/app/components/vendor-form-panel/create-form.js +1 -0
- package/app/components/vendor-form-panel/edit-form.js +1 -0
- package/app/components/vendor-form-panel.js +1 -0
- package/app/components/vendor-panel/details.js +1 -0
- package/app/components/vendor-panel.js +1 -0
- package/app/controllers/management/contacts/index/details.js +1 -0
- package/app/controllers/management/contacts/index/edit.js +1 -0
- package/app/controllers/management/contacts/index/new.js +1 -0
- package/app/controllers/management/fuel-reports/index/details.js +1 -0
- package/app/controllers/management/fuel-reports/index/edit.js +1 -0
- package/app/controllers/management/fuel-reports/index/new.js +1 -0
- package/app/controllers/management/issues/index/details.js +1 -0
- package/app/controllers/management/issues/index/edit.js +1 -0
- package/app/controllers/management/issues/index/new.js +1 -0
- package/app/controllers/management/places/index/details.js +1 -0
- package/app/controllers/management/places/index/edit.js +1 -0
- package/app/controllers/management/places/index/new.js +1 -0
- package/app/controllers/management/vendors/index/edit.js +1 -0
- package/app/controllers/management/vendors/index/new.js +1 -0
- package/app/routes/addon/routes/management/places/index/new.js +1 -0
- package/app/routes/management/contacts/index/details.js +1 -0
- package/app/routes/management/contacts/index/edit.js +1 -0
- package/app/routes/management/contacts/index/new.js +1 -0
- package/app/routes/management/fuel-reports/index/details.js +1 -0
- package/app/routes/management/fuel-reports/index/edit.js +1 -0
- package/app/routes/management/fuel-reports/index/new.js +1 -0
- package/app/routes/management/issues/index/details.js +1 -0
- package/app/routes/management/issues/index/edit.js +1 -0
- package/app/routes/management/issues/index/new.js +1 -0
- package/app/routes/management/places/index/details.js +1 -0
- package/app/routes/management/places/index/edit.js +1 -0
- package/app/routes/management/places/index/new.js +1 -0
- package/app/routes/management/vendors/index/details.js +1 -0
- package/app/routes/management/vendors/index/edit.js +1 -0
- package/app/routes/management/vendors/index/new.js +1 -0
- package/app/templates/addon/routes/management/places/index/new.js +1 -0
- package/app/templates/management/contacts/index/details.js +1 -0
- package/app/templates/management/contacts/index/edit.js +1 -0
- package/app/templates/management/contacts/index/new.js +1 -0
- package/app/templates/management/fuel-reports/index/details.js +1 -0
- package/app/templates/management/fuel-reports/index/edit.js +1 -0
- package/app/templates/management/fuel-reports/index/new.js +1 -0
- package/app/templates/management/issues/index/details.js +1 -0
- package/app/templates/management/issues/index/edit.js +1 -0
- package/app/templates/management/issues/index/new.js +1 -0
- package/app/templates/management/places/index/details.js +1 -0
- package/app/templates/management/places/index/edit.js +1 -0
- package/app/templates/management/places/index/new.js +1 -0
- package/app/templates/management/vendors/index/details.js +1 -0
- package/app/templates/management/vendors/index/edit.js +1 -0
- package/app/templates/management/vendors/index/new.js +1 -0
- package/app/utils/create-full-calendar-event-from-order.js +1 -0
- package/composer.json +1 -1
- package/config/environment.js +2 -1
- package/extension.json +1 -1
- package/package.json +5 -4
- package/server/migrations/2023_11_03_072503_refactor_issues_table_columns.php +42 -0
- package/server/migrations/2023_11_06_040645_refactor_fuel_reports_table.php +38 -0
- package/server/src/Casts/Point.php +15 -1
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +33 -15
- package/server/src/Http/Filter/FleetFilter.php +7 -0
- package/server/src/Http/Filter/FuelReportFilter.php +58 -0
- package/server/src/Http/Filter/IssueFilter.php +69 -0
- package/server/src/Http/Filter/VehicleFilter.php +10 -0
- package/server/src/Http/Middleware/TransformLocationMiddleware.php +48 -0
- package/server/src/Http/Resources/v1/Driver.php +1 -0
- package/server/src/Http/Resources/v1/Fleet.php +20 -21
- package/server/src/Http/Resources/v1/FuelReport.php +37 -35
- package/server/src/Http/Resources/v1/Issue.php +77 -0
- package/server/src/Http/Resources/v1/ParentFleet.php +60 -0
- package/server/src/Http/Resources/v1/SubFleet.php +60 -0
- package/server/src/Http/Resources/v1/Vehicle.php +4 -2
- package/server/src/Integrations/Lalamove/Lalamove.php +6 -6
- package/server/src/Models/Contact.php +7 -0
- package/server/src/Models/Driver.php +1 -1
- package/server/src/Models/Fleet.php +35 -4
- package/server/src/Models/FuelReport.php +53 -3
- package/server/src/Models/Issue.php +106 -7
- package/server/src/Models/Order.php +22 -0
- package/server/src/Models/Vehicle.php +1 -1
- package/server/src/Models/VehicleDevice.php +4 -2
- package/server/src/Models/VehicleDeviceEvent.php +8 -4
- package/server/src/Notifications/OrderAssigned.php +0 -6
- package/server/src/Notifications/OrderCanceled.php +0 -6
- package/server/src/Notifications/OrderDispatchFailed.php +0 -6
- package/server/src/Notifications/OrderDispatched.php +0 -6
- package/server/src/Notifications/OrderPing.php +0 -6
- package/server/src/Notifications/OrderSplit.php +0 -6
- package/server/src/Observers/FleetObserver.php +19 -0
- package/server/src/Providers/FleetOpsServiceProvider.php +1 -0
- package/server/src/Providers/NotificationServiceProvider.php +1 -1
- package/server/src/routes.php +2 -2
- package/addon/components/full-calendar/draggable.js +0 -1
- package/addon/components/full-calendar.js +0 -1
|
@@ -75,6 +75,9 @@ class Fleet extends Model
|
|
|
75
75
|
*/
|
|
76
76
|
protected static $logName = 'fleet';
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* The flug options for this model.
|
|
80
|
+
*/
|
|
78
81
|
public function getSlugOptions(): SlugOptions
|
|
79
82
|
{
|
|
80
83
|
return SlugOptions::create()
|
|
@@ -108,7 +111,7 @@ class Fleet extends Model
|
|
|
108
111
|
*
|
|
109
112
|
* @var array
|
|
110
113
|
*/
|
|
111
|
-
protected $appends = ['photo_url', 'drivers_count', 'drivers_online_count'];
|
|
114
|
+
protected $appends = ['photo_url', 'drivers_count', 'drivers_online_count', 'vehicles_count', 'vehicles_online_count'];
|
|
112
115
|
|
|
113
116
|
/**
|
|
114
117
|
* The attributes excluded from the model's JSON form.
|
|
@@ -154,7 +157,15 @@ class Fleet extends Model
|
|
|
154
157
|
*/
|
|
155
158
|
public function parentFleet()
|
|
156
159
|
{
|
|
157
|
-
return $this->belongsTo(Fleet::class)->
|
|
160
|
+
return $this->belongsTo(Fleet::class)->without(['subFleets']);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
165
|
+
*/
|
|
166
|
+
public function subFleets()
|
|
167
|
+
{
|
|
168
|
+
return $this->hasMany(Fleet::class, 'parent_fleet_uuid', 'uuid')->without(['parentFleet']);
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
/**
|
|
@@ -180,7 +191,7 @@ class Fleet extends Model
|
|
|
180
191
|
*/
|
|
181
192
|
public function getPhotoUrlAttribute()
|
|
182
193
|
{
|
|
183
|
-
return data_get($this, 'photo.
|
|
194
|
+
return data_get($this, 'photo.url', 'https://s3.ap-northeast-2.amazonaws.com/fleetbase/public/default-fleet.png');
|
|
184
195
|
}
|
|
185
196
|
|
|
186
197
|
/**
|
|
@@ -194,7 +205,7 @@ class Fleet extends Model
|
|
|
194
205
|
}
|
|
195
206
|
|
|
196
207
|
/**
|
|
197
|
-
* Get the number of drivers in fleet.
|
|
208
|
+
* Get the number of online drivers in fleet.
|
|
198
209
|
*
|
|
199
210
|
* @return int
|
|
200
211
|
*/
|
|
@@ -202,4 +213,24 @@ class Fleet extends Model
|
|
|
202
213
|
{
|
|
203
214
|
return $this->drivers()->where('online', 1)->count();
|
|
204
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get the number of vehicles in fleet.
|
|
219
|
+
*
|
|
220
|
+
* @return int
|
|
221
|
+
*/
|
|
222
|
+
public function getVehiclesCountAttribute()
|
|
223
|
+
{
|
|
224
|
+
return $this->vehicles()->count();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Get the number of online vehicles in fleet.
|
|
229
|
+
*
|
|
230
|
+
* @return int
|
|
231
|
+
*/
|
|
232
|
+
public function getVehiclesOnlineCountAttribute()
|
|
233
|
+
{
|
|
234
|
+
return $this->vehicles()->where('online', 1)->count();
|
|
235
|
+
}
|
|
205
236
|
}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Models;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\Casts\Json;
|
|
5
6
|
use Fleetbase\FleetOps\Casts\Point;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
use Fleetbase\Models\Model;
|
|
8
9
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
9
10
|
use Fleetbase\Traits\HasPublicId;
|
|
10
11
|
use Fleetbase\Traits\HasUuid;
|
|
12
|
+
use Fleetbase\Traits\Searchable;
|
|
11
13
|
use Fleetbase\Traits\TracksApiCredential;
|
|
12
14
|
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
13
15
|
|
|
@@ -18,6 +20,7 @@ class FuelReport extends Model
|
|
|
18
20
|
use HasPublicId;
|
|
19
21
|
use HasApiModelBehavior;
|
|
20
22
|
use SpatialTrait;
|
|
23
|
+
use Searchable;
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* The database table used by the model.
|
|
@@ -38,14 +41,27 @@ class FuelReport extends Model
|
|
|
38
41
|
*
|
|
39
42
|
* @var array
|
|
40
43
|
*/
|
|
41
|
-
protected $searchableColumns = [];
|
|
44
|
+
protected $searchableColumns = ['report', 'vehicle.name', 'driver.name'];
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* The attributes that are mass assignable.
|
|
45
48
|
*
|
|
46
49
|
* @var array
|
|
47
50
|
*/
|
|
48
|
-
protected $fillable = [
|
|
51
|
+
protected $fillable = [
|
|
52
|
+
'company_uuid',
|
|
53
|
+
'driver_uuid',
|
|
54
|
+
'vehicle_uuid',
|
|
55
|
+
'reported_by_uuid',
|
|
56
|
+
'report',
|
|
57
|
+
'odometer',
|
|
58
|
+
'location',
|
|
59
|
+
'amount',
|
|
60
|
+
'currency',
|
|
61
|
+
'volume',
|
|
62
|
+
'metric_unit',
|
|
63
|
+
'meta',
|
|
64
|
+
];
|
|
49
65
|
|
|
50
66
|
/**
|
|
51
67
|
* The attributes that are spatial columns.
|
|
@@ -61,6 +77,7 @@ class FuelReport extends Model
|
|
|
61
77
|
*/
|
|
62
78
|
protected $casts = [
|
|
63
79
|
'location' => Point::class,
|
|
80
|
+
'meta' => Json::class,
|
|
64
81
|
];
|
|
65
82
|
|
|
66
83
|
/**
|
|
@@ -68,7 +85,7 @@ class FuelReport extends Model
|
|
|
68
85
|
*
|
|
69
86
|
* @var array
|
|
70
87
|
*/
|
|
71
|
-
protected $appends = ['vehicle_name', 'driver_name'];
|
|
88
|
+
protected $appends = ['vehicle_name', 'driver_name', 'reporter_name'];
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
* The attributes excluded from the model's JSON form.
|
|
@@ -77,6 +94,13 @@ class FuelReport extends Model
|
|
|
77
94
|
*/
|
|
78
95
|
protected $hidden = ['driver', 'vehicle'];
|
|
79
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Filterable attributes/parameters.
|
|
99
|
+
*
|
|
100
|
+
* @var array
|
|
101
|
+
*/
|
|
102
|
+
protected $filterParams = ['type', 'status', 'reporter'];
|
|
103
|
+
|
|
80
104
|
/**
|
|
81
105
|
* Set the parcel fee as only numbers.
|
|
82
106
|
*
|
|
@@ -103,6 +127,22 @@ class FuelReport extends Model
|
|
|
103
127
|
return $this->belongsTo(Vehicle::class)->without(['driver']);
|
|
104
128
|
}
|
|
105
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
132
|
+
*/
|
|
133
|
+
public function reportedBy()
|
|
134
|
+
{
|
|
135
|
+
return $this->belongsTo(\Fleetbase\Models\User::class);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
140
|
+
*/
|
|
141
|
+
public function reporter()
|
|
142
|
+
{
|
|
143
|
+
return $this->belongsTo(\Fleetbase\Models\User::class, 'reported_by_uuid');
|
|
144
|
+
}
|
|
145
|
+
|
|
106
146
|
/**
|
|
107
147
|
* Get the driver's name assigned to vehicle.
|
|
108
148
|
*
|
|
@@ -122,4 +162,14 @@ class FuelReport extends Model
|
|
|
122
162
|
{
|
|
123
163
|
return data_get($this, 'vehicle.display_name');
|
|
124
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get the vehicless name.
|
|
168
|
+
*
|
|
169
|
+
* @var Model
|
|
170
|
+
*/
|
|
171
|
+
public function getReporterNameAttribute()
|
|
172
|
+
{
|
|
173
|
+
return data_get($this, 'reportedBy.name');
|
|
174
|
+
}
|
|
125
175
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Models;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\Casts\Json;
|
|
5
6
|
use Fleetbase\FleetOps\Casts\Point;
|
|
6
7
|
use Fleetbase\Models\Model;
|
|
7
8
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
@@ -9,6 +10,7 @@ use Fleetbase\Traits\HasPublicId;
|
|
|
9
10
|
use Fleetbase\Traits\HasUuid;
|
|
10
11
|
use Fleetbase\Traits\TracksApiCredential;
|
|
11
12
|
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
13
|
+
use Illuminate\Support\Str;
|
|
12
14
|
|
|
13
15
|
class Issue extends Model
|
|
14
16
|
{
|
|
@@ -46,18 +48,19 @@ class Issue extends Model
|
|
|
46
48
|
*/
|
|
47
49
|
protected $fillable = [
|
|
48
50
|
'_key',
|
|
51
|
+
'public_id',
|
|
49
52
|
'company_uuid',
|
|
50
53
|
'reported_by_uuid',
|
|
51
|
-
'vehicle_uuid',
|
|
52
54
|
'assigned_to_uuid',
|
|
55
|
+
'vehicle_uuid',
|
|
56
|
+
'driver_uuid',
|
|
53
57
|
'issue_id',
|
|
54
|
-
'odometer',
|
|
55
58
|
'location',
|
|
56
|
-
'
|
|
57
|
-
'longitude',
|
|
59
|
+
'category',
|
|
58
60
|
'type',
|
|
59
61
|
'report',
|
|
60
62
|
'priority',
|
|
63
|
+
'meta',
|
|
61
64
|
'resolved_at',
|
|
62
65
|
'status',
|
|
63
66
|
];
|
|
@@ -67,16 +70,32 @@ class Issue extends Model
|
|
|
67
70
|
*
|
|
68
71
|
* @var array
|
|
69
72
|
*/
|
|
70
|
-
protected $spatialFields = [
|
|
71
|
-
|
|
73
|
+
protected $spatialFields = ['location'];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The attributes that should be cast to native types.
|
|
77
|
+
*
|
|
78
|
+
* @var array
|
|
79
|
+
*/
|
|
80
|
+
protected $casts = [
|
|
81
|
+
'location' => Point::class,
|
|
82
|
+
'meta' => Json::class,
|
|
83
|
+
'resolved_at' => 'date',
|
|
72
84
|
];
|
|
73
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Filterable attributes/parameters.
|
|
88
|
+
*
|
|
89
|
+
* @var array
|
|
90
|
+
*/
|
|
91
|
+
protected $filterParams = ['assignee', 'reporter'];
|
|
92
|
+
|
|
74
93
|
/**
|
|
75
94
|
* Dynamic attributes that are appended to object.
|
|
76
95
|
*
|
|
77
96
|
* @var array
|
|
78
97
|
*/
|
|
79
|
-
protected $appends = [];
|
|
98
|
+
protected $appends = ['driver_name', 'vehicle_name', 'assignee_name', 'reporter_name'];
|
|
80
99
|
|
|
81
100
|
/**
|
|
82
101
|
* The attributes excluded from the model's JSON form.
|
|
@@ -93,6 +112,14 @@ class Issue extends Model
|
|
|
93
112
|
return $this->belongsTo(\Fleetbase\Models\User::class);
|
|
94
113
|
}
|
|
95
114
|
|
|
115
|
+
/**
|
|
116
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
117
|
+
*/
|
|
118
|
+
public function reporter()
|
|
119
|
+
{
|
|
120
|
+
return $this->belongsTo(\Fleetbase\Models\User::class, 'reported_by_uuid');
|
|
121
|
+
}
|
|
122
|
+
|
|
96
123
|
/**
|
|
97
124
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
98
125
|
*/
|
|
@@ -101,6 +128,14 @@ class Issue extends Model
|
|
|
101
128
|
return $this->belongsTo(\Fleetbase\Models\User::class);
|
|
102
129
|
}
|
|
103
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
133
|
+
*/
|
|
134
|
+
public function assignee()
|
|
135
|
+
{
|
|
136
|
+
return $this->belongsTo(\Fleetbase\Models\User::class, 'assigned_to_uuid');
|
|
137
|
+
}
|
|
138
|
+
|
|
104
139
|
/**
|
|
105
140
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
106
141
|
*/
|
|
@@ -108,4 +143,68 @@ class Issue extends Model
|
|
|
108
143
|
{
|
|
109
144
|
return $this->belongsTo(Vehicle::class);
|
|
110
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
149
|
+
*/
|
|
150
|
+
public function driver()
|
|
151
|
+
{
|
|
152
|
+
return $this->belongsTo(Driver::class);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Set a default status if none is provided, and always dasherize status input.
|
|
157
|
+
*
|
|
158
|
+
* @param string $value
|
|
159
|
+
*
|
|
160
|
+
* @return void
|
|
161
|
+
*/
|
|
162
|
+
public function setStatusAttribute($value)
|
|
163
|
+
{
|
|
164
|
+
if (empty($value)) {
|
|
165
|
+
$this->attributes['status'] = 'pending';
|
|
166
|
+
} else {
|
|
167
|
+
$this->attributes['status'] = Str::slug($value);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the driver's name assigned to vehicle.
|
|
173
|
+
*
|
|
174
|
+
* @return string
|
|
175
|
+
*/
|
|
176
|
+
public function getDriverNameAttribute()
|
|
177
|
+
{
|
|
178
|
+
return data_get($this, 'driver.name');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get the vehicless name.
|
|
183
|
+
*
|
|
184
|
+
* @return string
|
|
185
|
+
*/
|
|
186
|
+
public function getVehicleNameAttribute()
|
|
187
|
+
{
|
|
188
|
+
return data_get($this, 'vehicle.display_name');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Get the reporter name.
|
|
193
|
+
*
|
|
194
|
+
* @return string
|
|
195
|
+
*/
|
|
196
|
+
public function getReporterNameAttribute()
|
|
197
|
+
{
|
|
198
|
+
return data_get($this, 'reporter.name');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get the assignee name.
|
|
203
|
+
*
|
|
204
|
+
* @return string
|
|
205
|
+
*/
|
|
206
|
+
public function getAssigneeNameAttribute()
|
|
207
|
+
{
|
|
208
|
+
return data_get($this, 'assignee.name');
|
|
209
|
+
}
|
|
111
210
|
}
|
|
@@ -947,6 +947,28 @@ class Order extends Model
|
|
|
947
947
|
$this->customer_type = Utils::getModelClassName($model);
|
|
948
948
|
}
|
|
949
949
|
|
|
950
|
+
public function setCustomerTypeAttribute($type)
|
|
951
|
+
{
|
|
952
|
+
if (is_string($type)) {
|
|
953
|
+
if ($type === 'customer' || $type === 'vendor' || !Str::startsWith($type, 'fleet-ops')) {
|
|
954
|
+
$type = 'fleet-ops:' . $type;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
$this->attributes['customer_type'] = Utils::getMutationType($type);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
public function setFacilitatorTypeAttribute($type)
|
|
962
|
+
{
|
|
963
|
+
if (is_string($type)) {
|
|
964
|
+
if ($type === 'customer' || $type === 'vendor' || !Str::startsWith($type, 'fleet-ops')) {
|
|
965
|
+
$type = 'fleet-ops:' . $type;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
$this->attributes['facilitator_type'] = Utils::getMutationType($type);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
950
972
|
public function setDriverLocationAsPickup($force = false)
|
|
951
973
|
{
|
|
952
974
|
if ($force === true) {
|
|
@@ -10,7 +10,9 @@ use Fleetbase\Traits\TracksApiCredential;
|
|
|
10
10
|
|
|
11
11
|
class VehicleDevice extends Model
|
|
12
12
|
{
|
|
13
|
-
use HasUuid
|
|
13
|
+
use HasUuid;
|
|
14
|
+
use TracksApiCredential;
|
|
15
|
+
use HasApiModelBehavior;
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* The database table used by the model.
|
|
@@ -80,7 +82,7 @@ class VehicleDevice extends Model
|
|
|
80
82
|
*/
|
|
81
83
|
public function vehicle()
|
|
82
84
|
{
|
|
83
|
-
return $this->belongsTo(Vehicle::class);
|
|
85
|
+
return $this->belongsTo(Vehicle::class)->without(['events']);
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
/**
|
|
@@ -13,7 +13,11 @@ use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
|
13
13
|
|
|
14
14
|
class VehicleDeviceEvent extends Model
|
|
15
15
|
{
|
|
16
|
-
use HasUuid
|
|
16
|
+
use HasUuid;
|
|
17
|
+
use TracksApiCredential;
|
|
18
|
+
use HasApiModelBehavior;
|
|
19
|
+
use SpatialTrait;
|
|
20
|
+
use Searchable;
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* The database table used by the model.
|
|
@@ -47,8 +51,8 @@ class VehicleDeviceEvent extends Model
|
|
|
47
51
|
* @var array
|
|
48
52
|
*/
|
|
49
53
|
protected $casts = [
|
|
50
|
-
'payload'
|
|
51
|
-
'meta'
|
|
54
|
+
'payload' => Json::class,
|
|
55
|
+
'meta' => Json::class,
|
|
52
56
|
'location' => Point::class,
|
|
53
57
|
];
|
|
54
58
|
|
|
@@ -85,6 +89,6 @@ class VehicleDeviceEvent extends Model
|
|
|
85
89
|
*/
|
|
86
90
|
public function device()
|
|
87
91
|
{
|
|
88
|
-
return $this->belongsTo(VehicleDevice::class);
|
|
92
|
+
return $this->belongsTo(VehicleDevice::class, 'vehicle_device_uuid');
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -32,22 +32,16 @@ class OrderAssigned extends Notification implements ShouldQueue
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Notification name.
|
|
35
|
-
*
|
|
36
|
-
* @var string
|
|
37
35
|
*/
|
|
38
36
|
public static string $name = 'Order Assigned';
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
* Notification description.
|
|
42
|
-
*
|
|
43
|
-
* @var string
|
|
44
40
|
*/
|
|
45
41
|
public static string $description = 'Notify when an order has been assigned to a driver.';
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* Notification package.
|
|
49
|
-
*
|
|
50
|
-
* @var string
|
|
51
45
|
*/
|
|
52
46
|
public static string $package = 'fleet-ops';
|
|
53
47
|
|
|
@@ -32,22 +32,16 @@ class OrderCanceled extends Notification implements ShouldQueue
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Notification name.
|
|
35
|
-
*
|
|
36
|
-
* @var string
|
|
37
35
|
*/
|
|
38
36
|
public static string $name = 'Order Canceled';
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
* Notification description.
|
|
42
|
-
*
|
|
43
|
-
* @var string
|
|
44
40
|
*/
|
|
45
41
|
public static string $description = 'Notify when an order has been canceled.';
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* Notification package.
|
|
49
|
-
*
|
|
50
|
-
* @var string
|
|
51
45
|
*/
|
|
52
46
|
public static string $package = 'fleet-ops';
|
|
53
47
|
|
|
@@ -31,22 +31,16 @@ class OrderDispatchFailed extends Notification implements ShouldQueue
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Notification name.
|
|
34
|
-
*
|
|
35
|
-
* @var string
|
|
36
34
|
*/
|
|
37
35
|
public static string $name = 'Order dispatch Failed';
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* Notification description.
|
|
41
|
-
*
|
|
42
|
-
* @var string
|
|
43
39
|
*/
|
|
44
40
|
public static string $description = 'Notify when an order dispatch has been failed.';
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* Notification package.
|
|
48
|
-
*
|
|
49
|
-
* @var string
|
|
50
44
|
*/
|
|
51
45
|
public static string $package = 'fleet-ops';
|
|
52
46
|
|
|
@@ -35,22 +35,16 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Notification name.
|
|
38
|
-
*
|
|
39
|
-
* @var string
|
|
40
38
|
*/
|
|
41
39
|
public static string $name = 'Order Dispatched';
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Notification description.
|
|
45
|
-
*
|
|
46
|
-
* @var string
|
|
47
43
|
*/
|
|
48
44
|
public static string $description = 'Notify when an order has been dispatched.';
|
|
49
45
|
|
|
50
46
|
/**
|
|
51
47
|
* Notification package.
|
|
52
|
-
*
|
|
53
|
-
* @var string
|
|
54
48
|
*/
|
|
55
49
|
public static string $package = 'fleet-ops';
|
|
56
50
|
|
|
@@ -39,22 +39,16 @@ class OrderPing extends Notification implements ShouldQueue
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Notification name.
|
|
42
|
-
*
|
|
43
|
-
* @var string
|
|
44
42
|
*/
|
|
45
43
|
public static string $name = 'Order Ping';
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
46
|
* Notification description.
|
|
49
|
-
*
|
|
50
|
-
* @var string
|
|
51
47
|
*/
|
|
52
48
|
public static string $description = 'Notify when an order has been pinged.';
|
|
53
49
|
|
|
54
50
|
/**
|
|
55
51
|
* Notification package.
|
|
56
|
-
*
|
|
57
|
-
* @var string
|
|
58
52
|
*/
|
|
59
53
|
public static string $package = 'fleet-ops';
|
|
60
54
|
|
|
@@ -20,22 +20,16 @@ class OrderSplit extends Notification
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Notification name.
|
|
23
|
-
*
|
|
24
|
-
* @var string
|
|
25
23
|
*/
|
|
26
24
|
public static string $name = 'Order Split';
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* Notification description.
|
|
30
|
-
*
|
|
31
|
-
* @var string
|
|
32
28
|
*/
|
|
33
29
|
public static string $description = 'Notify when an order has been splited.';
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
32
|
* Notification package.
|
|
37
|
-
*
|
|
38
|
-
* @var string
|
|
39
33
|
*/
|
|
40
34
|
public static string $package = 'fleet-ops';
|
|
41
35
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Observers;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Fleet;
|
|
6
|
+
|
|
7
|
+
class FleetObserver
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Handle the Driver "deleted" event.
|
|
11
|
+
*
|
|
12
|
+
* @return void
|
|
13
|
+
*/
|
|
14
|
+
public function deleted(Fleet $fleet)
|
|
15
|
+
{
|
|
16
|
+
// If the fleet being deleted is set as parent fleet, remove it as the parent fleet
|
|
17
|
+
$subFleets = Fleet::where(['parent_fleet_uuid' => $fleet->uuid])->update(['parent_fleet_uuid' => null]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -31,6 +31,7 @@ class FleetOpsServiceProvider extends CoreServiceProvider
|
|
|
31
31
|
\Fleetbase\FleetOps\Models\TrackingNumber::class => \Fleetbase\FleetOps\Observers\TrackingNumberObserver::class,
|
|
32
32
|
\Fleetbase\FleetOps\Models\Driver::class => \Fleetbase\FleetOps\Observers\DriverObserver::class,
|
|
33
33
|
\Fleetbase\FleetOps\Models\Vehicle::class => \Fleetbase\FleetOps\Observers\VehicleObserver::class,
|
|
34
|
+
\Fleetbase\FleetOps\Models\Fleet::class => \Fleetbase\FleetOps\Observers\FleetObserver::class,
|
|
34
35
|
\Fleetbase\Models\User::class => \Fleetbase\FleetOps\Observers\UserObserver::class,
|
|
35
36
|
];
|
|
36
37
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Providers;
|
|
4
4
|
|
|
5
|
-
use Fleetbase\Support\NotificationRegistry;
|
|
6
5
|
use Fleetbase\Providers\CoreServiceProvider;
|
|
6
|
+
use Fleetbase\Support\NotificationRegistry;
|
|
7
7
|
|
|
8
8
|
if (!class_exists(CoreServiceProvider::class)) {
|
|
9
9
|
throw new \Exception('FleetOps cannot be loaded without `fleetbase/core-api` installed!');
|
package/server/src/routes.php
CHANGED
|
@@ -23,7 +23,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
|
|
|
23
23
|
| End-user API routes, these are routes that the SDK and applications will interface with, and require API credentials.
|
|
24
24
|
*/
|
|
25
25
|
Route::prefix('v1')
|
|
26
|
-
->middleware('fleetbase.api')
|
|
26
|
+
->middleware(['fleetbase.api', \Fleetbase\FleetOps\Http\Middleware\TransformLocationMiddleware::class])
|
|
27
27
|
->namespace('Api\v1')
|
|
28
28
|
->group(function ($router) {
|
|
29
29
|
// drivers routes
|
|
@@ -185,7 +185,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
|
|
|
185
185
|
$router->prefix(config('fleetops.api.routing.internal_prefix', 'int'))->namespace('Internal')->group(
|
|
186
186
|
function ($router) {
|
|
187
187
|
$router->group(
|
|
188
|
-
['prefix' => 'v1', 'namespace' => 'v1', 'middleware' => ['fleetbase.protected']],
|
|
188
|
+
['prefix' => 'v1', 'namespace' => 'v1', 'middleware' => ['fleetbase.protected', \Fleetbase\FleetOps\Http\Middleware\TransformLocationMiddleware::class]],
|
|
189
189
|
function ($router) {
|
|
190
190
|
$router->fleetbaseRoutes(
|
|
191
191
|
'contacts',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@fleetbase/console/components/full-calendar/draggable';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@fleetbase/console/components/full-calendar';
|