diff --git a/composer.json b/composer.json index 723932ad..fa78253d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/fleetops-api", - "version": "0.4.22", + "version": "0.4.23", "description": "Fleet & Transport Management Extension for Fleetbase", "keywords": [ "fleetbase-extension", @@ -22,7 +22,7 @@ ], "require": { "php": "^8.0", - "fleetbase/core-api": "^1.4.14", + "fleetbase/core-api": "^1.4.15", "barryvdh/laravel-dompdf": "^2.0", "brick/geo": "0.7.2", "cknow/laravel-money": "^7.1", diff --git a/extension.json b/extension.json index b0204c29..bbc0ff6d 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Fleet-Ops", - "version": "0.4.22", + "version": "0.4.23", "description": "Fleet & Transport Management Extension for Fleetbase", "repository": "https://github.com/fleetbase/fleetops", "license": "MIT", diff --git a/package.json b/package.json index 1bbc27f3..dc857582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/fleetops-engine", - "version": "0.4.22", + "version": "0.4.23", "description": "Fleet & Transport Management Extension for Fleetbase", "fleetbase": { "route": "fleet-ops" diff --git a/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php b/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php index 3289db9c..8e6a5883 100644 --- a/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php +++ b/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php @@ -36,7 +36,7 @@ public function handle() ['model' => \Fleetbase\FleetOps\Models\Order::class, 'columns' => ['customer_type', 'facilitator_type']], ['model' => \Fleetbase\FleetOps\Models\Place::class, 'columns' => ['owner_type']], ['model' => \Fleetbase\FleetOps\Models\Entity::class, 'columns' => ['customer_type']], - ['model' => \Fleetbase\FleetOps\Models\PurchaseRate::class, 'columns' => ['customer_type']], + ['model' => \Fleetbase\FleetOps\Models\PurchaseRate::class, 'columns' => ['customer_type']] ]; foreach ($models as $modelConfig) { diff --git a/server/src/Http/Controllers/Api/v1/DriverController.php b/server/src/Http/Controllers/Api/v1/DriverController.php index 5fc51b84..a27b41c1 100644 --- a/server/src/Http/Controllers/Api/v1/DriverController.php +++ b/server/src/Http/Controllers/Api/v1/DriverController.php @@ -500,7 +500,7 @@ public function verifyCode(Request $request) return response()->apiError($e->getMessage()); } - // $driver->update(['auth_token' => $token->plainTextToken]); + $driver->update(['auth_token' => $token->plainTextToken]); $driver->token = $token->plainTextToken; return new DriverResource($driver); @@ -597,7 +597,8 @@ public function switchOrganization(string $id, SwitchOrganizationRequest $reques } // Assign user to company and update their session - $user->assignCompany($company); + $user->update(['company_uuid' => $company->uuid]); + Auth::setSession($user); return new Organization($company); @@ -772,4 +773,4 @@ private static function phone(?string $phone = null): string return $phone; } -} +} \ No newline at end of file diff --git a/server/src/Http/Controllers/Api/v1/OrderController.php b/server/src/Http/Controllers/Api/v1/OrderController.php index 77a8fec0..c050b0e6 100644 --- a/server/src/Http/Controllers/Api/v1/OrderController.php +++ b/server/src/Http/Controllers/Api/v1/OrderController.php @@ -434,6 +434,7 @@ public function update($id, UpdateOrderRequest $request) public function query(Request $request) { $results = Order::queryWithRequest($request, function (&$query, $request) { + $query->where('company_uuid', session('company')); if ($request->has('payload')) { $query->whereHas('payload', function ($q) use ($request) { $q->where('public_id', $request->input('payload')); @@ -495,9 +496,9 @@ public function query(Request $request) }); } - if ($request->has('on')) { - $on = Carbon::fromString($request->input('on')); - + if ($request->filled('on')) { + $on = Carbon::parse($request->input('on')); + $query->where(function ($q) use ($on) { $q->whereDate('created_at', $on); $q->orWhereDate('scheduled_at', $on); @@ -1401,14 +1402,10 @@ public function getEditableEntityFields(string $id, Request $request) // Get entity editing settings $savedEntityEditingSettings = Setting::where('key', 'fleet-ops.entity-editing-settings')->value('value'); - if ($orderConfigId && $savedEntityEditingSettings) { - $resolvedEntityEditingSettings = data_get($savedEntityEditingSettings, $orderConfigId, []); - if ($resolvedEntityEditingSettings) { - $entityEditingSettings = data_get($resolvedEntityEditingSettings, 'editable_entity_fields', []); - } + $entityEditingSettings = data_get($savedEntityEditingSettings, $orderConfigId, []); } return response()->json($entityEditingSettings); } -} +} \ No newline at end of file diff --git a/server/src/Http/Controllers/FleetOpsController.php b/server/src/Http/Controllers/FleetOpsController.php index 051d2da4..d8783222 100644 --- a/server/src/Http/Controllers/FleetOpsController.php +++ b/server/src/Http/Controllers/FleetOpsController.php @@ -11,10 +11,4 @@ class FleetOpsController extends FleetbaseController * The package namespace used to resolve from. */ public string $namespace = '\\Fleetbase\\FleetOps'; - - public function test() - { - $order = Order::where('public_id', '')->first(); - dd($order->config()->getNextActivity()); - } } diff --git a/server/src/Http/Filter/OrderFilter.php b/server/src/Http/Filter/OrderFilter.php index 0f714a8b..2dbff6d8 100644 --- a/server/src/Http/Filter/OrderFilter.php +++ b/server/src/Http/Filter/OrderFilter.php @@ -38,7 +38,7 @@ function ($q) { public function queryForPublic() { - $this->builder->where('company_uuid', $this->session->get('company'))->whereHas('trackingNumber')->whereHas('payload'); + $this->builder->where('company_uuid', $this->session->get('company')); } public function unassigned(bool $unassigned) diff --git a/server/src/Http/Requests/CreateContactRequest.php b/server/src/Http/Requests/CreateContactRequest.php index fc211afd..b17223a1 100644 --- a/server/src/Http/Requests/CreateContactRequest.php +++ b/server/src/Http/Requests/CreateContactRequest.php @@ -14,7 +14,7 @@ class CreateContactRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('storefront_key') || request()->session()->has('api_credential'); + return request()->session()->has('storefront_key') || request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; } /** diff --git a/server/src/Http/Requests/CreateDriverRequest.php b/server/src/Http/Requests/CreateDriverRequest.php index dbfb5ad5..90f8fce2 100644 --- a/server/src/Http/Requests/CreateDriverRequest.php +++ b/server/src/Http/Requests/CreateDriverRequest.php @@ -15,7 +15,7 @@ class CreateDriverRequest extends FleetbaseRequest */ public function authorize() { - return request()->is('navigator/v1/*') || request()->session()->has('api_credential'); + return request()->is('navigator/v1/*') || request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /** diff --git a/server/src/Http/Requests/CreateEntityRequest.php b/server/src/Http/Requests/CreateEntityRequest.php index 39dadba8..96a9f7f3 100644 --- a/server/src/Http/Requests/CreateEntityRequest.php +++ b/server/src/Http/Requests/CreateEntityRequest.php @@ -14,7 +14,7 @@ class CreateEntityRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential'); + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; } /** diff --git a/server/src/Http/Requests/CreateIssueRequest.php b/server/src/Http/Requests/CreateIssueRequest.php index 62a2a853..c63ea808 100644 --- a/server/src/Http/Requests/CreateIssueRequest.php +++ b/server/src/Http/Requests/CreateIssueRequest.php @@ -6,6 +6,21 @@ class CreateIssueRequest extends FleetbaseRequest { + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ public function rules() { return [ diff --git a/server/src/Http/Requests/CreatePlaceRequest.php b/server/src/Http/Requests/CreatePlaceRequest.php index fce9d484..926c82ff 100644 --- a/server/src/Http/Requests/CreatePlaceRequest.php +++ b/server/src/Http/Requests/CreatePlaceRequest.php @@ -16,9 +16,7 @@ class CreatePlaceRequest extends FleetbaseRequest */ public function authorize() { - return request() - ->session() - ->has('api_credential'); + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; } /** diff --git a/server/src/Http/Requests/CreateVehicleRequest.php b/server/src/Http/Requests/CreateVehicleRequest.php index a0ce4842..479438f5 100644 --- a/server/src/Http/Requests/CreateVehicleRequest.php +++ b/server/src/Http/Requests/CreateVehicleRequest.php @@ -14,7 +14,7 @@ class CreateVehicleRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential'); + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; } /** diff --git a/server/src/Http/Resources/v1/Driver.php b/server/src/Http/Resources/v1/Driver.php index 0ce292ee..c7650b5d 100644 --- a/server/src/Http/Resources/v1/Driver.php +++ b/server/src/Http/Resources/v1/Driver.php @@ -53,7 +53,7 @@ public function toArray($request) 'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)), 'online' => data_get($this, 'online', false), 'status' => $this->status, - 'token' => data_get($this, 'token'), + 'token' => $this->auth_token, 'meta' => $this->meta, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at,