Skip to content

Commit 6ed65bc

Browse files
authored
Merge pull request #143 from fleetbase/dev-v1.6.4
Cannot use facade before root facade set patch
2 parents 54b79c7 + 9c67e27 commit 6ed65bc

File tree

8 files changed

+18
-16
lines changed

8 files changed

+18
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/core-api",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"description": "Core Framework and Resources for Fleetbase API",
55
"keywords": [
66
"fleetbase",

config/database.connections.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
$username = env('DB_USERNAME', 'fleetbase');
88
$password = env('DB_PASSWORD', '');
99

10-
if ($databaseUrl = getenv('DATABASE_URL')) {
10+
$databaseUrl = getenv('DATABASE_URL');
11+
if (!empty($databaseUrl)) {
1112
$url = Utils::parseUrl($databaseUrl);
1213

1314
$host = $url['host'];

src/Auth/GoogleVerifier.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Google_Client as GoogleClient;
66
use GuzzleHttp\Client as GuzzleClient;
7-
use Illuminate\Support\Facades\Log;
87

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

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

3433
return null;
3534
}

src/Events/ResourceLifecycleEvent.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Illuminate\Queue\SerializesModels;
1515
use Illuminate\Support\Arr;
1616
use Illuminate\Support\Carbon;
17-
use Illuminate\Support\Facades\Log;
1817
use Illuminate\Support\Str;
1918

2019
class ResourceLifecycleEvent implements ShouldBroadcastNow
@@ -150,7 +149,7 @@ public function broadcastOn()
150149
{
151150
$model = $this->getModelRecord();
152151
if (!$model) {
153-
Log::error('Unable to resolve a model to broadcast for', $this->getInternalEventData());
152+
logger()->error('Unable to resolve a model to broadcast for', $this->getInternalEventData());
154153

155154
return [];
156155
}
@@ -342,7 +341,7 @@ public function getEventData()
342341
{
343342
$model = $this->getModelRecord();
344343
if (!$model) {
345-
Log::error('Unable to resolve a model to get event data for', $this->getInternalEventData());
344+
logger()->error('Unable to resolve a model to get event data for', $this->getInternalEventData());
346345

347346
return [];
348347
}

src/Exceptions/Handler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Fleetbase\Support\Utils;
66
use Illuminate\Auth\AuthenticationException;
77
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8-
use Illuminate\Support\Facades\Log;
98

109
class Handler extends ExceptionHandler
1110
{
@@ -62,7 +61,7 @@ protected function unauthenticated($request, AuthenticationException $exception)
6261
public function report(\Throwable $exception)
6362
{
6463
// Log to CloudWatch
65-
Log::error($this->getCloudwatchLoggableException($exception));
64+
logger()->error($this->getCloudwatchLoggableException($exception));
6665

6766
parent::report($exception);
6867
}

src/Listeners/SendResourceLifecycleWebhook.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Illuminate\Contracts\Queue\ShouldQueue;
1414
use Illuminate\Database\QueryException;
1515
use Illuminate\Support\Carbon;
16-
use Illuminate\Support\Facades\Log;
1716
use Illuminate\Support\Str;
1817
use Laravel\Sanctum\PersonalAccessToken;
1918

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

7069
return;
7170
}
@@ -110,7 +109,7 @@ public function handle($event)
110109
$request = $exception->getRequest();
111110

112111
// Log error
113-
Log::error($exception->getMessage());
112+
logger()->error($exception->getMessage());
114113

115114
// Prepare log data
116115
$webhookRequestLogData = [

src/Support/NotificationRegistry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static function getNotifiablesForCompany(string $companyId): array
165165
// If dynamic create a string representation
166166
if (Str::startsWith($notifiableClass, 'dynamic:')) {
167167
$dynamicNotifiable = str_replace('dynamic:', '', $notifiableClass);
168-
$notifiables[] = [
168+
$notifiables[] = [
169169
'label' => 'Dynamic: ' . Str::title($dynamicNotifiable),
170170
'key' => $dynamicNotifiable,
171171
'primaryKey' => 'uuid',
@@ -344,7 +344,7 @@ public static function notifyUsingDefinitionName($notificationClass, $notificati
344344
*
345345
* @param array $notifiableObject an associative array containing the definition and primary key to resolve the notifiable object
346346
*
347-
* @return \Illuminate\Database\Eloquent\Model|null the Eloquent model or null if it cannot be resolved
347+
* @return Model|null the Eloquent model or null if it cannot be resolved
348348
*/
349349
protected static function resolveNotifiable(array $notifiableObject, $subject): ?Model
350350
{
@@ -361,7 +361,7 @@ protected static function resolveNotifiable(array $notifiableObject, $subject):
361361
} else {
362362
$modelInstance = $subject->{$property};
363363
}
364-
364+
365365
if ($modelInstance instanceof Model) {
366366
return $modelInstance;
367367
}

src/Support/Utils.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,8 +2588,13 @@ public static function clearCacheByPattern(string $pattern): void
25882588
* $result = arrayFrom($person);
25892589
* // Result: ['name' => 'John', 'age' => 30]
25902590
*/
2591-
public static function arrayFrom(array|string|object $target): array
2591+
public static function arrayFrom(array|string|object|null $target): array
25922592
{
2593+
// if target is null return empty array
2594+
if (is_null($target)) {
2595+
return [];
2596+
}
2597+
25932598
if (is_array($target)) {
25942599
// If the target is already an array, return it as is.
25952600
return $target;

0 commit comments

Comments
 (0)