Skip to content

Commit

Permalink
Merge pull request #50 from mohamadtsn/support-new-laravel
Browse files Browse the repository at this point in the history
Laravel 10 Support
  • Loading branch information
hosseinRezaei188 authored Mar 2, 2023
2 parents f054f95 + 81579bc commit d66dc5c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
vendor
composer.lock
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- V.6
- V.7
- V.8
- **V.9**
- V.9
- **V.10**
> We highly recomment you to always use the latest version of laravel
# Installation
Expand Down
22 changes: 4 additions & 18 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,11 @@ private function getProvider()

$version = intval($app::VERSION);

switch ($version) {
case 4:
return new ServiceProviderLaravel4($app);

case 5:
return new ServiceProviderLaravel5($app);

case 6:
return new ServiceProviderLaravel6($app);

case 7:
return new ServiceProviderLaravel7($app);
case 8:
return new ServiceProviderLaravel8($app);
case 9:
return new ServiceProviderLaravel9($app);
default:
throw new RuntimeException('Your version of Laravel is not supported');
$provider_name = "Kavenegar\\Laravel\\ServiceProviderLaravel" . $version;
if (class_exists($provider_name)) {
return new $provider_name($app);
}
throw new RuntimeException('Your version of Laravel is not supported');
}

/**
Expand Down
38 changes: 38 additions & 0 deletions src/ServiceProviderLaravel10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Kavenegar\Laravel;

use Kavenegar\KavenegarApi as KavenegarApi;
use Illuminate\Support\Facades\Notification;
use Kavenegar\Laravel\Channel\KavenegarChannel;

class ServiceProviderLaravel10 extends \Illuminate\Support\ServiceProvider
{
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->publishes([__DIR__ . '/config/config.php' => config_path('kavenegar.php')]);
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'kavenegar');
$this->app->singleton('kavenegar', function ($app) {
return new KavenegarApi($app['config']->get('kavenegar.apikey'));
});
Notification::resolved(function ($service) {
$service->extend('kavenegar', function ($app) {
return new KavenegarChannel($app->make('kavenegar'));
});
});
}
}

0 comments on commit d66dc5c

Please sign in to comment.