From 9a02ecf9ccbe7b8f0c040f8047504576cbbeb49d Mon Sep 17 00:00:00 2001 From: Tymotheos Szulc Date: Tue, 5 Sep 2023 12:51:11 -0400 Subject: [PATCH] feat: add support for laravel 8 Based on brozot/Laravel-FCM#217 --- composer.json | 10 +++++----- src/FCMManager.php | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 37b1c45f7..881652a7d 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ } ], "require": { - "php": "^7.2.5", - "illuminate/support": "^6.0|^7.0", + "php": "^7.2.5|^8.0", + "illuminate/support": "^6.0|^7.0|^8.0", "guzzlehttp/guzzle": "^6.3|^7.0", "monolog/monolog": "^1.12|^2.0" }, "require-dev": { - "mockery/mockery" : "^1.3.1", - "phpunit/phpunit" : "^8.4|^9.3", - "laravel/laravel": "^6.0|^7.0", + "mockery/mockery" : "^1.3.1|^1.4.4", + "phpunit/phpunit" : "^8.4|^9.3|^9.5", + "laravel/laravel": "^6.0|^7.0|^8.0", "php-coveralls/php-coveralls": "^2.0" }, "autoload": { diff --git a/src/FCMManager.php b/src/FCMManager.php index 6a2402722..e7ccc99a1 100644 --- a/src/FCMManager.php +++ b/src/FCMManager.php @@ -9,13 +9,29 @@ class FCMManager extends Manager { public function getDefaultDriver() { - return $this->app[ 'config' ][ 'fcm.driver' ]; + return $this->getContainer()[ 'config' ][ 'fcm.driver' ]; } protected function createHttpDriver() { - $config = $this->app[ 'config' ]->get('fcm.http', []); + $config = $this->getContainer()[ 'config' ]->get('fcm.http', []); return new Client(['timeout' => $config[ 'timeout' ]]); } + + /** + * Get the app container + * + * @return \Illuminate\Contracts\Container\Container + */ + public function getContainer() + { + // Laravel 7.x, 8.x support + if (isset($this->container)) { + return $this->container; + } + + // "app" Does not exist anymore in 8.x + return $this->app; + } }