Skip to content

Commit

Permalink
Fix talk class not found issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nahid authored Jul 2, 2018
1 parent 17c2ba4 commit dcd6d06
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/TalkServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Nahid\Talk;

use Illuminate\Container\Container;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
Expand Down Expand Up @@ -37,11 +38,11 @@ protected function setupConfig()
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([$source => config_path('talk.php')]);
}

if ($this->app instanceof LumenApplication) {
$this->app->configure('talk');
}

$this->mergeConfigFrom($source, 'talk');
}
/**
Expand All @@ -58,23 +59,35 @@ protected function setupMigrations()
*/
protected function registerTalk()
{
$this->app->singleton(Talk::class, function ($app) {
return new Talk(
$app['config'],
$app[Live\Broadcast::class],
$app[ConversationRepository::class],
$app[MessageRepository::class]
);
$this->app->singleton('talk', function (Container $app) {
return new Talk($app['config'], $app['talk.broadcast'], $app[ConversationRepository::class], $app[MessageRepository::class]);
});

$this->app->alias('talk', Talk::class);
}

/**
* Register Talk class.
*/
protected function registerBroadcast()
{
$this->app->singleton(Live\Broadcast::class, function ($app) {
$this->app->singleton('talk.broadcast', function (Container $app) {
return new Live\Broadcast($app['config']);
});

$this->app->alias('talk.broadcast', Live\Broadcast::class);
}

/**
* Get the services provided by the provider.
*
* @return string[]
*/
public function provides()
{
return [
'talk',
'talk.broadcast',
];
}
}

0 comments on commit dcd6d06

Please sign in to comment.