Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/core-api",
"version": "1.6.3",
"version": "1.6.4",
"description": "Core Framework and Resources for Fleetbase API",
"keywords": [
"fleetbase",
Expand Down
3 changes: 2 additions & 1 deletion config/database.connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
$username = env('DB_USERNAME', 'fleetbase');
$password = env('DB_PASSWORD', '');

if ($databaseUrl = getenv('DATABASE_URL')) {
$databaseUrl = getenv('DATABASE_URL');
if (!empty($databaseUrl)) {
$url = Utils::parseUrl($databaseUrl);

$host = $url['host'];
Expand Down
3 changes: 1 addition & 2 deletions src/Auth/GoogleVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Google_Client as GoogleClient;
use GuzzleHttp\Client as GuzzleClient;
use Illuminate\Support\Facades\Log;

class GoogleVerifier
{
Expand All @@ -29,7 +28,7 @@ public static function verifyIdToken(string $idToken, string $clientId): ?array

return null;
} catch (\Exception $e) {
Log::error('Google ID Token verification failed: ' . $e->getMessage());
logger()->error('Google ID Token verification failed: ' . $e->getMessage());

return null;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Events/ResourceLifecycleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class ResourceLifecycleEvent implements ShouldBroadcastNow
Expand Down Expand Up @@ -150,7 +149,7 @@ public function broadcastOn()
{
$model = $this->getModelRecord();
if (!$model) {
Log::error('Unable to resolve a model to broadcast for', $this->getInternalEventData());
logger()->error('Unable to resolve a model to broadcast for', $this->getInternalEventData());

return [];
}
Expand Down Expand Up @@ -342,7 +341,7 @@ public function getEventData()
{
$model = $this->getModelRecord();
if (!$model) {
Log::error('Unable to resolve a model to get event data for', $this->getInternalEventData());
logger()->error('Unable to resolve a model to get event data for', $this->getInternalEventData());

return [];
}
Expand Down
3 changes: 1 addition & 2 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Fleetbase\Support\Utils;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;

class Handler extends ExceptionHandler
{
Expand Down Expand Up @@ -62,7 +61,7 @@ protected function unauthenticated($request, AuthenticationException $exception)
public function report(\Throwable $exception)
{
// Log to CloudWatch
Log::error($this->getCloudwatchLoggableException($exception));
logger()->error($this->getCloudwatchLoggableException($exception));

parent::report($exception);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Listeners/SendResourceLifecycleWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\QueryException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Laravel\Sanctum\PersonalAccessToken;

Expand Down Expand Up @@ -65,7 +64,7 @@ public function handle($event)
// log the api event
$apiEvent = ApiEvent::create($eventData);
} catch (\Exception|QueryException $e) {
Log::error($e->getMessage());
logger()->error($e->getMessage());

return;
}
Expand Down Expand Up @@ -110,7 +109,7 @@ public function handle($event)
$request = $exception->getRequest();

// Log error
Log::error($exception->getMessage());
logger()->error($exception->getMessage());

// Prepare log data
$webhookRequestLogData = [
Expand Down
6 changes: 3 additions & 3 deletions src/Support/NotificationRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static function getNotifiablesForCompany(string $companyId): array
// If dynamic create a string representation
if (Str::startsWith($notifiableClass, 'dynamic:')) {
$dynamicNotifiable = str_replace('dynamic:', '', $notifiableClass);
$notifiables[] = [
$notifiables[] = [
'label' => 'Dynamic: ' . Str::title($dynamicNotifiable),
'key' => $dynamicNotifiable,
'primaryKey' => 'uuid',
Expand Down Expand Up @@ -344,7 +344,7 @@ public static function notifyUsingDefinitionName($notificationClass, $notificati
*
* @param array $notifiableObject an associative array containing the definition and primary key to resolve the notifiable object
*
* @return \Illuminate\Database\Eloquent\Model|null the Eloquent model or null if it cannot be resolved
* @return Model|null the Eloquent model or null if it cannot be resolved
*/
protected static function resolveNotifiable(array $notifiableObject, $subject): ?Model
{
Expand All @@ -361,7 +361,7 @@ protected static function resolveNotifiable(array $notifiableObject, $subject):
} else {
$modelInstance = $subject->{$property};
}

if ($modelInstance instanceof Model) {
return $modelInstance;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Support/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2588,8 +2588,13 @@ public static function clearCacheByPattern(string $pattern): void
* $result = arrayFrom($person);
* // Result: ['name' => 'John', 'age' => 30]
*/
public static function arrayFrom(array|string|object $target): array
public static function arrayFrom(array|string|object|null $target): array
{
// if target is null return empty array
if (is_null($target)) {
return [];
}

if (is_array($target)) {
// If the target is already an array, return it as is.
return $target;
Expand Down